Programmatically remove deleted notifications from action center
How can we pragmatically remove any pending remote notifications sent for my app from notification center. I want to clear them when the application starts.
I tried with API [[UIApplication sharedApplication] cancelAllLocalNotifications];
but didn't help.
PS: This question is specific to iOS 10 and the old streams are not duplicates for this.
source to share
You can clear all notifications from notification center using these simple lines of code
[[UIApplication sharedApplication] setApplicationIconBadgeNumber: 1];
[[UIApplication sharedApplication] setApplicationIconBadgeNumber: 0];
[[UIApplication sharedApplication] cancelAllLocalNotifications];
use wherever you want. For my part, I used when the user clicked the logout button. You can use in
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
method for clearing notifications after opening the app
source to share
This can of course be achieved with the removeDeliveredNotifications (withIdentifiers :) method available in UserNotifications.framework.
For detailed tutorial please follow this
https://medium.com/@sebastianosiski/implementing-removable-remote-notifications-on-ios-a17d74832bde
source to share