Micah
Micah

Reputation: 1716

Toggle On/Off All UILocalNotifications

I have an iOS 7 application that allows for scheduling n number of UILocalNotifications.

I would like to add a switch on the app settings view to toggle all UILocalNotifications On/Off. In other words, how can I suspend all the UILocalNotifications and re-activate them on demand?

[[UIApplication sharedApplication] cancelAllLocalNotifications];

If I do that it seems to delete them and I'm not sure how to get them back and re-activate.

Thanks in advance.

Upvotes: 2

Views: 90

Answers (1)

Rick Roberts
Rick Roberts

Reputation: 895

I would keep track of the notifications created using some type of persistence. Flag each of these with an "enabled" status. When you "cancelAllNotifications" you should set each enabled status to "NO". Then when you want to enable all notifications again you should loop through and recreate a notification for each object where enabled == NO.

Upvotes: 2

Related Questions