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 !!
Asked
Active
Viewed 103 times
1
-
What kind of notification do you implement? – voltae Feb 25 '17 at 12:33
-
No they don't. Just make sure you remove all pending notifications on first run. – pronebird Feb 25 '17 at 12:34
-
[centerNotification removeAllPendingNotificationRequests]; here is the code i use to cancel notification. – kishan Feb 25 '17 at 13:06
-
1@Andy hey you are right, these are no pending notification, it is already notified but it is on repeat mode, repeating after every hour – kishan Feb 25 '17 at 13:10
1 Answers
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