iOS 9 & 9.1: Repeating UILocalNotification cannot be cancelled without restarting device

Originator:mail.junjie
Number:rdar://22702989 Date Originated:16-Sep-2015
Status:Open/Duplicate of 22348044 Resolved:
Product:iOS Product Version:iOS 9 GM & iOS 9.1 beta 1
Classification:Serious Bug Reproducible:Always
 
Description:

In iOS 9 and 9.1, when an app is updated (via TestFlight and possibly from the App Store), and subsequently calls [UIApplication setScheduledLocalNotifications:] twice, it causes any existing notifications to be stuck in the system. Notifications with repeatInterval will continue firing over and over again with no way for the app to cancel these notifications (they no longer exist in [UIApplication scheduledLocalNotifications]), until the device is restarted.


Steps to Reproduce:

1. Watch the attached video on how the bug is reproduced on sample app (https://vimeo.com/139360427)
2. Launch attached sample app. Better if you upload to TestFlight and install the sample app on actual device. I've better luck reproducing it on an actual device than simulator. (https://dl.dropboxusercontent.com/u/2943526/StuckLocalNotifications.zip)
3. Tap on 'Schedule Notifications'. This calls [UIApplication setScheduledLocalNotifications:] with 64 notifications created at 5 minute intervals, with repeatInterval set to NSCalendarUnitMinute. Each time 'Schedule Notifications' is triggered, a new set of 64 notifications is created. They are differentiated by the alphabet that increments from A-Z.
4. Increment the build number. Compile another build for the device. If possible, upload to TestFlight and update the app from  TestFlight.
5. Launch the updated app on the device.
6. Tap on 'Schedule Notifications' twice. It doesn't have to be fast. It just happens when [UIApplication setScheduledLocalNotifications:] is called twice after the update.
7. Exit to home screen and wait for the bug to take place (i.e. you'll see notifications that have already been replaced in step 6)
8. If you do not experience the bug, repeat step 6-7 again.
9. If you still do not experience the bug, repeat step 4-7. Again, this works "better" on an actual device.


Expected Results:

Notifications that were replaced with [UIApplication setScheduledLocalNotifications:] are cancelled and no longer gets fired by iOS.


Actual Results:

1. Notifications that were replaced with [UIApplication setScheduledLocalNotifications:] continues to fire. 
2. These phantom notifications are not reflected in [UIApplication scheduledLocalNotifications], and cannot be cancelled without restarting the device


Configuration:

iPhone 6 Plus, iPhone 6, Simulator (sometimes). iOS 9 GM, iOS 9.1 beta 1


Version & Build:

iOS 9 GM and iOS 9.1 beta 1


Additional Notes:

This is possibly related to the bug first introduced in iOS 5. See rdar://11136251 and rdar://12072780. The problem was still rather rare then. However, on iOS 9, this can be easily reproduced.


Update to radar on 24-Sep-2015 09:06 AM:

This problem persists on iOS 9.0.1 released today. In fact, updating iOS from 9.0 to 9.0.1 actually triggers the problem once again. This means that for every iOS update released by Apple where this bug is not fixed, every single user of mine will experience this bug, and will be forced to restart their device if they know about this solution. Otherwise, they'll attempt to delete my app (which does not resolve the issue), leave bad reviews (doesn't resolve the issue either), ask for refund, or send me a lot of emails…

Comments

Update to radar on 24-Sep-2015 09:06 AM

This problem persists on iOS 9.0.1 released today. In fact, updating iOS from 9.0 to 9.0.1 actually triggers the problem once again. This means that for every iOS update released by Apple where this bug is not fixed, every single user of mine will experience this bug, and will be forced to restart their device if they know about this solution. Otherwise, they'll attempt to delete my app (which does not resolve the issue), leave bad reviews (doesn't resolve the issue either), ask for refund, or send me a lot of emails…


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!