play system sound for UILocalNotification

Hey,


I would like to know if it's possible to play one of the system sounds for a UILocalNoification?


For example I would like to do something like this: localNotification.soundName = "/Library/RingtonesApex.m4r"


But that doesn't work. Is there a solution for this? Because I don't want to import custom sounds if there are already useable sounds for notifications on the device.

Other than UILocalNotificationDefaultSoundName, no, it isn't possible to access other system sounds outside the sandbox.

You can implement the following lines on didReceiveLocalNotification:


// default sound 1315 - on an iPhone, may also vibrate the device, depending on the user's settings

let systemSoundID: SystemSoundID = 1315

AudioServicesPlayAlertSound (systemSoundID)


Here you can find more of those sounds: http://iphonedevwiki.net/index.php/AudioServices

There’s two problems with this:

  • didReceiveLocalNotification
    only gets called if your app is running when the notification is delivered. It doesn’t help you when the app is suspended in the background.
  • These sound IDs are not public API.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

WWDC runs Mon, 13 Jun through to Fri, 17 Jun. During that time all of DTS will be at the conference, helping folks out face-to-face. http://developer.apple.com/wwdc/

play system sound for UILocalNotification
 
 
Q