0

I know it's possible to delete a local push notification (How to delete a local notification in iPhone)

But what if my users set a notification a week ago?

How can I iterate through these notifications, find the one I want to delete and delete it?

I'm guessing that they must be app specific, so I could delete all the notifications and then have a routine which submits new ones?

Are there any good examples or tutorials online?

Community
  • 1
  • 1
Jules
  • 7,568
  • 14
  • 102
  • 186

2 Answers2

4

To delete all of your local notifications, you can do the following:

[[UIApplication sharedApplication] cancelAllLocalNotifications];

Have fun!

averydev
  • 5,717
  • 2
  • 35
  • 35
3

You can get a list of all scheduled local notifications with:

NSArray* notifications = [[UIApplication sharedApplication] scheduledLocalNotifications];

You can then iterate through that array and create a new array. Since iOS 4.2 you can then schedule the new notification array easily with:

[UIApplication sharedApplication].scheduledLocalNotifications = notifications;

Earlier you had to call scheduleLocalNotification: for each new notification.

Felix
  • 35,354
  • 13
  • 96
  • 143
  • Can I delete all the notifications for my app? maybe that's the best option for compatibility with older phones. But can I delete all from my app ? – Jules Dec 04 '11 at 12:25
  • @Jules deletes all scheduled notifications: `[UIApplication sharedApplication].scheduledLocalNotifications = [NSArray array];` – Felix Dec 04 '11 at 13:18