iPhone: how to remove badge after Push Notification?
objC :
[UIApplication sharedApplication].applicationIconBadgeNumber = 0;
swift :
UIApplication.sharedApplication().applicationIconBadgeNumber = 0;
You can remove badge from push notifications by adding the following lines to your code
(void)applicationDidBecomeActive:(UIApplication *)application{ [[UIApplication sharedApplication] cancelAllLocalNotifications]; [UIApplication sharedApplication].applicationIconBadgeNumber = 0;}
As for iOS5, just setting badge number won't remove those push notification in the notification center. You have to do this...
[[UIApplication sharedApplication] cancelAllLocalNotifications];[UIApplication sharedApplication].applicationIconBadgeNumber = 0;
I already tested this. It looks like cancelAllLocalNotifications
method also works with push notifications in notification center as well.