Remove single remote notification from Notification Center Remove single remote notification from Notification Center ios ios

Remove single remote notification from Notification Center


There is no way to remove a specific notification as of iOS SDK 5.0. The way to remove all the notifications from your app so they don't show in the Notification Center when the user opens the app from one of them, is to set the app badge to 0, like this:

[UIApplication sharedApplication].applicationIconBadgeNumber = 0;

EDIT: on iOS 8, SpringBoard seems to be automatically dismissing a notification when you tap on it on the Notification Center to open the app.


Here is a suggestion, though it does have its flaws, and I haven't tried it myself:

  • Push a silent notification (contentAvailable:true), don't include a "alert" inside the push, place the alert text in a custom property of the push
  • Handle the incoming push and trigger a local notification, display it immediately
  • If the user clicks the local notification, use the [UIApplication cancelLocalNotification:] which should remove the notification from the notification center.


When you call the method:[application cancelAllLocalNotifications];inside the AppDelegate methods:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

and

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo

All Local and Push Notifications will be remove on that for the particular app.