0

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 ?

PJR
  • 13,052
  • 13
  • 64
  • 104

2 Answers2

2

You can cancel all notifications with :

[[UIApplication sharedApplication] cancelAllLocalNotifications];

or you can cancel a single one like :

[[UIApplication sharedApplication] cancelLocalNotification:theNotification];

Hope this helps.

blackcj
  • 3,651
  • 2
  • 25
  • 23
Popeye
  • 11,839
  • 9
  • 58
  • 91
0

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

Riddick
  • 400
  • 2
  • 9