iOS开发极光推送遇到的问题

极光推送文档:https://docs.jiguang.cn/jpush/client/iOS/ios_api/#apns

// 前台收到推送消息,未点击情况执行

- (void)jpushNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(NSInteger))completionHandler;

// 点击推送消息获取信息

- (void)jpushNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)())completionHandler;

如果 App 状态为未运行,此函数将被调用,如果launchOptions包含UIApplicationLaunchOptionsRemoteNotificationKey表示用户点击apn 通知导致app被启动运行;如果不含有对应键值则表示 App 不是因点击apn而被启动,可能为直接点击icon被启动或其他。

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
// apn 内容获取:
NSDictionary *remoteNotification = [launchOptions objectForKey: UIApplicationLaunchOptionsRemoteNotificationKey];
}

设置Badge

value 取值范围:[0,99999]

+ (BOOL)setBadge:(int)value

设置badge值,本地仍须调用UIApplication:setApplicationIconBadgeNumber函数

调用此 API 来设置别名,支持回调函数

+ (void)setTags:(NSSet *)tags
          alias:(NSString *)alias
    fetchCompletionHandle:(void (^)(int iResCode, NSSet *iTags, NSString *iAlias))completionHandler;

例: 如果移除别名,alisa可以传空字符串

[JPUSHService setTags:nil alias:@"1" fetchCompletionHandle:^(int iResCode, NSSet *iTags, NSString *iAlias) {
    if (iResCode == 0) {
        //设置成功
    }
}];

你可能感兴趣的:(iOS开发极光推送遇到的问题)