I am developing an iPhone app where the user can schedule local notifications as reminders.
In the applicationDidBecomeActive method, I am checking the expire dates of each scheduled notification and cancel the notifications which are expired.
Now my question is, if I delete the application from the phone and re-install, all the scheduled notifications (which are not expire yet) are still there.
BUT, my requirement is to cancel all the scheduled local notifications if the user delete the application for the phone.
How can I do it with
[[UIApplication sharedApplication] cancelAllLocalNotifications]
-
You can't - if the user deletes the app and doesn't re-install it then iOS will clean up the notifications for you.Paulw11– Paulw112015年03月09日 11:30:32 +00:00Commented Mar 9, 2015 at 11:30
-
You won't be able to store any information outside your application, when the app is deleted everything related gets deleted also.user623396– user6233962015年03月09日 11:33:53 +00:00Commented Mar 9, 2015 at 11:33
-
@user623396 If the expire date does not exceed, local notifications are still there when you delete the app and re-installsmartsanja– smartsanja2015年03月09日 11:50:38 +00:00Commented Mar 9, 2015 at 11:50
-
check this post to know how use cancelAllLocalNotificationsHuy Nghia– Huy Nghia2015年03月09日 11:52:10 +00:00Commented Mar 9, 2015 at 11:52
1 Answer 1
NSUserDefaults are deleted if you delete the app - so you could set an NSUserDefault with some value, and check it when the app starts up.
If the value is nil, you know it's either a fresh install or that the app has been deleted. Then you can call to cancel the local notifications.
After canceling the existing notifications (if it's a fresh install, nothing will happen anyway since there will be no notifications), you can set the NSUserDefault again, so that next time the cancel operation won't be called.
1 Comment
Explore related questions
See similar questions with these tags.