0

I would like to clear delivered notifications from notification centre based on what a user does. So, if they view a certain screen, remove the relevant notification etc.

There may be more than one delivered notification for the app, but I may not want to clear all of them.

How can I list all the delivered notifications that are showing in notification centre from my app, and then programatically remove the relevant notification?

I have looked at this thread Can I programmatically clear my app's notifications from the iOS 5 Notification Center? however it does not seem to show how I can list delivered notifications so that I can then programatically remove the relevant one(s).

Community
  • 1
  • 1
NeilMortonNet
  • 1,500
  • 4
  • 16
  • 36

2 Answers2

0

As per Martin H You can't do this. You can either delete them all or none of them. You can't delete individual ones.

NeilMortonNet
  • 1,500
  • 4
  • 16
  • 36
0

I have several types of notifications and I selectively remove notifications based on user interactions. Simply reference the name of your Notification variable and remove it.

var notification_1:UILocalNotification = UILocalNotification()
....
var notification_1:UILocalNotification = UILocalNotification()
....
UIApplication.sharedApplication().cancelLocalNotification(notification_1)

It may not be the best method, but it seems to work. See this answer too: Removing a notification from notification center on click

Community
  • 1
  • 1
Freedlun
  • 79
  • 10