iOS前台远程推送问题
这次问的有点奇葩....
首先. 远程推送
然后. App 后台/杀死 点击通知 都会走的那个方法
- (void)jpushNotificationCenter:(UNUserNotificationCenter *)center
didReceiveNotificationResponse:(UNNotificationResponse *)response
withCompletionHandler:(void (^)())completionHandler
这里面实现的没有问题了.
若App在前台的时候接受到通知 走的方法:
- (void)jpushNotificationCenter:(UNUserNotificationCenter *)center
willPresentNotification:(UNNotification *)notification
withCompletionHandler:(void (^)(NSInteger))completionHandler
我在这里面要做的操作有几种
1.App运行的时候,
---->在主页面收到了推送 我设置了
completionHandler(UNNotificationPresentationOptionSound);
---->在次页面收到了推送 我设置了
completionHandler(UNNotificationPresentationOptionSound|
UNNotificationPresentationOptionAlert);
我想做的操作是 在现实alert的页面 出现alert之后 把通知中心的数量以及app的角标清空(实践中 角标清空了) 用的方法为
[[UIApplication sharedApplication] setApplicationIconBadgeNumber:0];
[[UIApplication sharedApplication] cancelAllLocalNotifications];
[JPUSHService setBadge:0];
然后尝试了
[[UIApplication sharedApplication] setApplicationIconBadgeNumber:1];
[[UIApplication sharedApplication] setApplicationIconBadgeNumber:0];
[[UIApplication sharedApplication] cancelAllLocalNotifications];
[JPUSHService setBadge:0];
最后试了断点之后 会走清空角标方法
想要在alert出现之后清空通知中心数量
我有设置了延迟3s 走上面清空个数的方法
结果还是没用
还有一个就是
如果我不显示alert的话 通知中心没有通知
那我怎么才能获取通知的个数,
若用户没有查看 怎么显示在app的角标上?