3

I am facing a weird problem with UILocalNotifiation. I was scheduling a local notification at 11:59 every night. Now, I have deleted that code from my project but I am still receiving that local notification every night at 11:59. I have tried to remove build from device, change device and clean derived data.

nburk
22.8k19 gold badges93 silver badges134 bronze badges
asked Mar 9, 2015 at 9:18
1
  • I also have the same issue , i don't know why local notification is being fired. As i deleted the code. Commented Mar 9, 2015 at 9:20

1 Answer 1

9

That's actually standard iOS behaviour, since you schedule the notifications on iOS (the actual operating system). This means, that once you scheduled a UILocalNotification, it will sit in the operating system until it either fires or gets cancelled manually.

So, for your case, it sounds like you initially scheduled a number of notifications, these are now all sitting in the operating system waiting to fire. They won't go away when you change your code or delete the app, they will only go away f you either delete them or when they get fired.

In order to make sure, you don't receive any notifications that have been scheduled in the past, you can delete them using:

[[UIApplication sharedApplication] cancelAllLocalNotifications];

You can also get all notifications that are currently scheduled by your app and cancel them individually:

NSArray *activeNotifications = [[UIApplication sharedApplication] scheduledLocalNotifications];
for (UILocalNotification *notification in activeNotifications) {
 [[UIApplication sharedApplication] cancelNotification:notification];
}
answered Mar 9, 2015 at 9:29
Sign up to request clarification or add additional context in comments.

Comments

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.