美文网首页
推送模块设置

推送模块设置

作者: aaa000 | 来源:发表于2017-07-14 10:09 被阅读9次

1.在libaray_configs.plist 文件中的 push_appkey 中设置在友盟平台上申请得到的appkey

2.xcode 中各种证书配置正确,然后在Target->Capabilities 打开Push Notification 开关


屏幕快照 2017-07-14 上午9.58.32.png

3.引入库文件 UserNotifications.framework 、libz.tbd 添加静态库.a文件的搜索路径

90FD6754-5A9F-49F4-9C30-B1FD10D407B9.png

4.初始化SDK和其他配置

#import "AppDelegate.h"
#import "RBPushManager.h"
#import <UserNotifications/UserNotifications.h>
@interface AppDelegate ()<UNUserNotificationCenterDelegate>

@end

@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    [RBPushManager applicationDidFinishLaunchingWithOptions:launchOptions];
    //iOS10必须加下面这段代码。
    UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
    center.delegate = self;
    UNAuthorizationOptions types = UNAuthorizationOptionBadge|  UNAuthorizationOptionAlert|UNAuthorizationOptionSound;
    [center requestAuthorizationWithOptions:types completionHandler:^(BOOL granted, NSError * _Nullable error) {
        if (granted) {
            [application registerForRemoteNotifications];
        }
    }];
    return YES;
}
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken{
    [RBPushManager didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];
}
//iOS10以下使用这个方法接收通知
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo{
    [RBPushManager didReceiveRemoteNotification:userInfo];
}
//iOS10新增:处理前台收到通知的代理方法
-(void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler{
    NSDictionary * userInfo = notification.request.content.userInfo;
    if([notification.request.trigger isKindOfClass:[UNPushNotificationTrigger class]]) {
         [RBPushManager didReceiveRemoteNotification:userInfo];
    }
    completionHandler(UNNotificationPresentationOptionSound|UNNotificationPresentationOptionBadge|UNNotificationPresentationOptionAlert);
}

//iOS10新增:处理后台点击通知的代理方法
-(void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)())completionHandler{
    NSDictionary * userInfo = response.notification.request.content.userInfo;
    if([response.notification.request.trigger isKindOfClass:[UNPushNotificationTrigger class]]) {
         [RBPushManager didReceiveRemoteNotification:userInfo];
    }
}

5.有关推送的其他功能调用

#import <Foundation/Foundation.h>

@interface RBPushManager : NSObject

/**
 处理收到的推送信息

 @param callback 收到推送信息回调
 */
+(void)handlePushInfos:(void (^)(NSDictionary *))callback;

/**
 初始化友盟推送SDK
 */
+(void)applicationDidFinishLaunchingWithOptions:(NSDictionary *)launchOptions;


/**
 注册设备Token
 */
+(void)didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken;


/**
 收到推送消息
 */
+(void)didReceiveRemoteNotification:(NSDictionary *)pushInfos;


/**
 为设备添加标签
 */
+(void)addDeviceTag:(NSString *)tag;


/**
 移除设备标签
 */
+(void)removeDeviceTag:(NSString *)tag;


/**
 获取设备的标签列表
 */
+(void)getAllTags:(void (^)(NSSet *))callback;


/**
 删除设备上的所有标签
 */
+(void)removeAllTags;



/**
 设备设置别名
 */
+(void)setAlias:(NSString *)name type:(NSString *)type;


/**
 删除设备别名
 */
+(void)removeAlias:(NSString *)name type:(NSString *)type;
@end

相关文章

  • 推送模块设置

    1.在libaray_configs.plist 文件中的 push_appkey 中设置在友盟平台上申请得到的a...

  • iOS 关于信鸽推送点击推送通知的处理

    最近的项目中使用了推送模块,使用的是企鹅帝国的信鸽推送服务,关于具体怎么推送的,证书如何设置,我不再赘述,一来开发...

  • 推送模块

    推送是通过第三方工具将信息发送给该用户终端种。分两种:一种是自动触发,需要定义触发条件一般根据业务进行定义。二是运...

  • EV3-超声波传感器判断距离

    选择切换模块 设置超声波传感器 移动转向模块 设置移动转向模块 设置循环模块

  • ansible模块

    ansible模块 shell模块 copy 推送文件模块 src=dest= backup= 把/etc/hos...

  • 2018年功能模块沉淀

    一、推送模块 1.极光推送 文档:https://www.jiguang.cn/push备注:极光推送包括普通推送...

  • jpush推送模块

    参考:https://github.com/kongdewen1994/ionic2-jpush-cordova-...

  • iOS 推送设置及相应处理

    推送设置 1.推送界面设置 在iOS8 之后,推送可以设置一些操作按钮,即使app在后台甚至是app被杀掉的情况下...

  • 推送证书设置

  • 中奖推送设置

    近期,我们更新了一个特殊的“中奖推送”功能,在以往的抽奖或游戏中奖中,用户中奖数据只能在后台查到,且活动后兑换时找...

网友评论

      本文标题:推送模块设置

      本文链接:https://www.haomeiwen.com/subject/fedwhxtx.html