Reputation: 13180
I am using Local notification in my application. Now if i remove my application from background then the notification is active. , i want to remove or cancel notifications whenf i remove app from background.
i write code for cancelation in applicationWillTerminate method but this method is not calling . any other help ?
Upvotes: 0
Views: 1405
Reputation: 12093
You can cancel all notifications with :
[[UIApplication sharedApplication] cancelAllLocalNotifications];
or you can cancel a single one like :
[[UIApplication sharedApplication] cancelLocalNotification:theNotification];
Hope this helps.
Upvotes: 2
Reputation: 400
The method you are searching is either
- (void)applicationWillEnterForeground:(UIApplication *)application
or
- (void)applicationDidBecomeActive:(UIApplication *)application
Inside one of those app delegate methods you should call
[[UIApplication sharedApplication] cancelAllLocalNotifications];
Here's more info: https://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/UIApplication_Class/Reference/Reference.html
Upvotes: 0