1

i am implementing UserNotification in an app, Now the thing is that once i set a notification with repeat of every minute, it works fine. Once i remove app from simulator and install again, the old set notification keeps on striking.Don't it get removed if i remove app from simulator? Any help !!

kishan
  • 203
  • 1
  • 6
  • 15

1 Answers1

0

Notifications may be scheduled for some time even after you remove and reinstall the app. Make sure that you cancel all scheduled notifications on the first run of your application.

You can use NSUserDefaults or on-disk storage to store a flag to find when your app runs in the very first time.

pronebird
  • 12,068
  • 5
  • 54
  • 82
  • tried to remove all pending as well delivered(those which are on repeat mode) notification – kishan Feb 25 '17 at 13:31
  • if(![[NSUserDefaults standardUserDefaults]boolForKey:@"bIsFirstLaunch"]){ if([[[UIDevice currentDevice] systemVersion] floatValue] < 10.0){ [[UIApplication sharedApplication] cancelAllLocalNotifications]; }else{ [centerNotification removeAllDeliveredNotifications]; [centerNotification removeAllPendingNotificationRequests]; } [[NSUserDefaults standardUserDefaults]setBool:YES forKey:@"bIsFirstLaunch"]; [[NSUserDefaults standardUserDefaults]synchronize]; } – kishan Feb 27 '17 at 05:34