I'd like to use a custom sound for Notification Center, but cannot find much documentation on this. I know how to assign a sound to a notification, and I know how to copy new sound files to ~/Library/Sounds then use these new sounds. My app is sandboxed so I of course have to ask the user to confirm they want to install the new sounds, but am concerned about App Store rejection based on this App Store rule:
2.15 Apps must be self-contained, single application installation bundles, and cannot install code or resources in shared locations
Anyways, is it possible to use a custom sound with a NSUserNotification without copying a resource to ~/Library/Sounds ?
Seems like there is documentation for this on iOS, but nothing for OS X.
Thanks in advance.
The comment by the declaration of the soundName
property of the NSUserNotification
class in the headers reads (emphasis added):
The name of the sound file in the resources of the application bundle to play when the notification is delivered. NSUserNotificationDefaultSoundName can be used to play the default Notification Center sound. A value of 'nil' means no sound.
So, you can simply ship a sound file in your app bundle's resources and use its name for the user notification's soundName
. Almost certainly, this is similar to the +[NSSound soundNamed:]
method, so you should pass the file name minus the file extension.