UserNotifications often fails to play custom UNNotificationSound

Originator:robotspacer
Number:rdar://28061207 Date Originated:29-Aug-2016 04:07 PM
Status:Open Resolved:
Product:iOS SDK Product Version:iOS 10 beta 8 (14A5346a)
Classification:Serious Bug Reproducible:Sometimes
 
Summary:
I've updated my app to use the new UserNotifications framework. When I create a local notification, I specify content.sound = [UNNotificationSound soundNamed:@"Ding.aif"]. The file Ding.aif is in my app's main bundle and it's in the correct format. However when the notification fires, it uses the default sound instead of my custom sound.

Here are some things I've tried unsuccessfully:

- I tried putting the sound directly in the main bundle as well as in Library/Sounds.
- I tried using soundNamed: with and without the extension. The documentation does not make it clear which is correct.
- My file is linear PCM in an AIFF container which the documentation says should be fine. The same file worked fine with the old local notification API in iOS 9.
- I tried changing the extension from aif to aiff.

How the app is installed seems to have some effect on the problem. For example if I build and run the app in Xcode, the custom sound never works for me. If I then archive the app, export it, and then install it by dragging it to the Devices window, it still fails to play. But if I completely delete the app and install it again that way, it works. I've seen others report that the problem only happens when they install via TestFlight, but I haven't had a chance to try that yet myself.

Steps to Reproduce:
1. Build and run the attached demo app.
2. Tap the button to allow notifications when prompted.
3. Tap the "Show notification in 15 seconds" button.
4. Close the app and wait for the notification to fire.

Expected Results:
The notification should appear and the custom sound Ding.aif should play.

Actual Results:
The notification appears and a sound plays, but often the default notification sound plays instead of the custom sound.

Version:
iOS 10 beta 8 (14A5346a)

Notes:
There's a thread on the forums here about this problem:
https://forums.developer.apple.com/thread/49512

Configuration:
iPhone 6s, AT&T, 128GB

Attachments:
'NotificationSound.zip' was successfully uploaded.

Comments


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!