Dismissing/Updating Local Notification Programmatically in iPhone sdk4
I am working on an app that runs in the background with the backgroundmode set to location. In the didUpdateToLocation: method, I want to generate local notification. I want the app to show the notification only when previous notification has been viewed. Another option is to show only the latest notification and dismiss all the 开发者_如何学Pythonprevious notifications programmatically (i.e. without user interaction). Please guide me how is it possible?
Try this:
UIApplication *app = [UIApplication sharedApplication];
NSArray *oldNotifications = [app scheduledLocalNotifications];
// Clear out the old notification before scheduling a new one.
if ([oldNotifications count] > 0) {
[app cancelAllLocalNotifications];
}
精彩评论