1

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]
asked Mar 9, 2015 at 11:27
4
  • You can't - if the user deletes the app and doesn't re-install it then iOS will clean up the notifications for you. Commented 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. Commented 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-install Commented Mar 9, 2015 at 11:50
  • check this post to know how use cancelAllLocalNotifications Commented Mar 9, 2015 at 11:52

1 Answer 1

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.

answered Mar 9, 2015 at 13:08
Sign up to request clarification or add additional context in comments.

1 Comment

Yes. I implement similar kind of solution using plists

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.