R3ptor R3ptor - 6 months ago 62
iOS Question

play system sound for UILocalNotification

I found this project on GitHub: iOS Sounds and Ringtones

Is there a way to play one of those sounds for

localNotification.soundName
?

So I got the string for
"/Library/RingtonesApex.m4r"


But it still plays the default notification sound.

Answer

UILocalNotification accepts only a sound file name, not a file path. And the docs for soundName explain that this file must be "...in the app’s main bundle...". Getting the path to a system sound file is not useful with UILocalNotification because that file is not in your app's main bundle, and because you can't tell UILocalNotification to look somewhere else.