I gather that IOS does not give you access to the notifications center in order to keep track of notitifications.
However, many apps do seem to keep track of notifications so that when you see the badge on your home screen or a notification fires and you tap inside the app you can view all the notifications. Linkedin does this for example.
In my case, all the notifications refer to managedobjects in one entity in core data so I tried to hack this by estimating which notifications should have fired given their timestamps in core data. However, this is proving to be an unreliable approach. A fetch that grabbed every item beginning with the first notification since last opened would have to know the time stamp of the first notification since last opened. However, while you know the current time, you don't really know the time of the first notification if you don't know what the first notification since the last opening of the app is.
Has anyone devised a way or know of a library to accurately track notifications? It occurred to me one way might be create an accessible doppelganger of the notificationcenter in core data or an array and keep the notifications there. But that's as far as I've gotten.
To create the cache of future notifications in the notification center, I just fetch anything with a date in the future from core data and add the notification to the notification center:
NSDate *now [NSDate* date];
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"event!=nil AND event.length>=1&&starttime>=now"];
//perform fetch code here
NSInteger resultCount = [fetchedObjects count];
UILocalNotification *reminderNotification;
for (int i = 0; i < resultCount; i++) {
reminderNotification = [[UILocalNotification alloc] init];
reminderNotification.fireDate = event.starttime;
reminderNotification.timeZone = [NSTimeZone defaultTimeZone];
reminderNotification.alertAction = @"View Event";
reminderNotification.alertBody = event.event;
reminderNotification.applicationIconBadgeNumber = resultCount+1;
//schedule the notification!
[[UIApplication sharedApplication]
scheduleLocalNotification:reminderNotification];
resultCount++;
}
Thanks in advance for any suggestions.