点击通知中心并启动应用程序后,是否可以从通知中心删除推送通知?
大多数应用程序似乎都留下了通知.我读了另一个问题:
[[UIApplication sharedApplication] setApplicationIconBadgeNumber:0];
可能会工作,但它不适用于我.
解决方法
int badgeCount = [UIApplication sharedApplication].applicationIconBadgeNumber; [[UIApplication sharedApplication] setApplicationIconBadgeNumber:0]; [[UIApplication sharedApplication] cancelAllLocalNotifications]; [[UIApplication sharedApplication] setApplicationIconBadgeNumber:badgeCount];
如果你把它添加到这两个
- (void)applicationWillEnterForeground:(UIApplication *)application
和
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions (NSDictionary *)launchOptions