iPhoneDv
iPhoneDv

Reputation: 1969

iOS 9.2.1, cancel notifcation not working

I'm developing an app having local notification scheduled. I'm not able to cancel the scheduled notification using the code:

UIApplication *app=[UIApplication sharedApplication];  
[app cancelLocalNotification:notification];

The code is working well in previous iOS versions, but it is stopped working in iOS 9.2.1 update.

Can anyone please help me to sort out the issue?

Upvotes: 1

Views: 96

Answers (2)

Hasya
Hasya

Reputation: 9898

Keep your localnotification object in NSUSerDefault when it is scheduling, even if your device gets restart you can retrieve localnotification object from NSUSerDefault. So then after you can easily pass that object in cancelLocalNotification(localNotificationObject) and remove it.

Upvotes: 0

Shashi
Shashi

Reputation: 28

There is a bug in iOS 9.2.1, so cancelLocalNotification methods doesn't work sometimes. Use cancelLocalAllNotifications and update your logic accordingly. This should work.

Upvotes: 1

Related Questions