How to clear notifications in IOS using Objective-C

To clear notifications in IOS using objective-c you can use the snippet below.

Sample Objective-C

//in method: application:didFinishLaunchingWithOptions
[[UIApplication sharedApplication] setApplicationIconBadgeNumber: 0];
[[UIApplication sharedApplication] cancelAllLocalNotifications];

//in method: application:didReceiveRemoteNotification
[[UIApplication sharedApplication] setApplicationIconBadgeNumber: 1]; //we need to to increment first
[[UIApplication sharedApplication] setApplicationIconBadgeNumber: 0];
[[UIApplication sharedApplication] cancelAllLocalNotifications];

Please Share us:
Please rate this snippet

4 thoughts on “How to clear notifications in IOS using Objective-C

Leave a Reply