Reputation: 1234
I am working on a project where I fire a local notification frequently also repeat notification. After fired notification, if I delete the application and install it again (without opening it), I get all the old notifications.
Upvotes: 3
Views: 2094
Reputation: 48
- (void)applicationWillTerminate:(UIApplication *)application
{
[[UIApplication sharedApplication] cancelAllLocalNotifications];
}
*and then set remaining all notification in*
- (void)applicationDidBecomeActive:(UIApplication *)application
{
UILocalNotification *notif = [[UILocalNotification alloc]init];
[[UIApplication sharedApplication] scheduleLocalNotification:notif];
}
Upvotes: 1
Reputation: 10752
put your code in App did finish launching method.so, when app launch then it's cancel the all notification.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
//cancel All notification when app is launch
[[UIApplication sharedApplication] cancelAllLocalNotifications];
return YES;
}
Pls note that it cancel the all notification. if u want to cancel any particular notification then set it's tag and using tag cancel this notification.
Upvotes: 0
Reputation: 4817
Try this:
-(void)clearNotifications
{
[[UIApplication sharedApplication] setApplicationIconBadgeNumber: 1];
[[UIApplication sharedApplication] setApplicationIconBadgeNumber: 0];
[[UIApplication sharedApplication] cancelAllLocalNotifications];
}
Upvotes: 1