UILocalNotification audio is not stopped if the notification is swiped from the lock screen.

Number:rdar://16623079 Date Originated:april 15, 2014
Status:Open Resolved:
Product:iOS Product Version:7.1
Classification:other bug Reproducible:always
Hi, we are using a UILocalNotification to play an incoming ring sound when users receive a phone call in our VoIP application.  We are consistently able to stop the audio sound by canceling all local notifications which is what we are looking to achieve.  However, when the alert shows up on the lock screen (and the phone does not require a passcode to open), acting on the alert does not stop the audio.  Despite the fact that during applicationWillEnterForeground we call the cancelAllLocalNotifications method.

Steps to Reproduce:
In your application, setup a UILocalNotification to trigger sometime in the future when your phone will be closed (so the alert will show up on the lock screen).  Set the audio value on the UILocalNotification to a sound file bundled with the application (probably something of a decent length so that its easy to test that it continues playing after the alert is acted upon, but not longer then the maximum length of 30 seconds).  In the app delegate you should implement the applicationWillEnterForeground delegate method and perform the following method call:

[[UIApplication sharedApplication] cancelAllLocalNotifications];

Also, ensure that the phone does not require a passcode to unlock the phone after acting on the notifications alert. (If the phone requires a passcode, the audio does stop as expected).

Expected Results:
The audio should no longer play once the application is opened.

Actual Results:
The audio continues to play from the local notification even though all notifications have been canceled.

Tested against the following:
- iOS 7.1 (11D167) model MD638LL/A
- iOS 7.1 (11D167) model MD277LL/A

I found a related Stack Overflow post that may be helpful as well: http://stackoverflow.com/questions/21122481/uilocalnotification-doesnt-stop-the-sound-when-the-application-is-brought-to-fo

Does not occur if the user needs to enter a passcode to unlock their phone after acting on the notification. 



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!