Is it possible to do this? UIApplication\'s
scheduledLocalNotifications
doesn\'t seem to return notifications that have already been delivered to t
You can solve this by adding your newly created notifications to your own NSMutableArray
of notifications and check that array instead of app.scheduledLocalNotifications
.
Something like this:
Add a NSMutableArray
to your Viewcontrollers .h file:
NSMutableArray *currentNotifications;
Initiate it when initiating your ViewController
currentNotifications = [[NSMutableArray alloc] init];
When initiating a notification, also add it to your array:
UILocalNotification *notification = [[UILocalNotification alloc] init];
...
[currentNotifications addObject:notification];
[[UIApplication sharedApplication] presentLocalNotificationNow:notification];
Later when you want to cancel that notification, look for it in your array instead. Also remove it from your array:
for (UILocalNotification *notification in currentNotifications) {
if (someCondition) {
[[UIApplication sharedApplication] cancelLocalNotification:notification];
[currentNotifications removeObject:notification];
}
}