Is it possible to do this? UIApplication\'s
scheduledLocalNotifications
doesn\'t seem to return notifications that have already been delivered to t
I've been looking for an answer to this as well. My problem was that I wanted to 'clean up' all app-related notifications sitting in the notification center just in case the user opens the app from its dock icon (since that does nothing to the previously fired notifications...)
Fortunately, it would appear that cancelAllNotifications
doesn't just cancel scheduled ones, but EVERYTHING. So I simply held on to a reference of the existing scheduled notifications before blasting them, and then rescheduled them accordingly:
UIApplication *app = [UIApplication sharedApplication];
NSLog(@"\nScheduled notif count (prior) = %d", app.scheduledLocalNotifications.count);
NSArray *scheduledNotifs = app.scheduledLocalNotifications; // hold on to a reference
[[UIApplication sharedApplication] cancelAllLocalNotifications]; // blast everything
NSLog(@"\nScheduled notif count (post-wipeout) = %d", app.scheduledLocalNotifications.count);
for (UILocalNotification *notif in scheduledNotifs) {
[app scheduleLocalNotification:notif]; // put them back
}
NSLog(@"\nScheduled notif count (post-repopulation) = %d", app.scheduledLocalNotifications.count);
Not sure if that helps anyone but this worked great for my situation.