Custom sounds may be provided for notifications generated by your app. When the system displays an alert for a local notification or badges an app icon, it plays this sound (so long as the user has not disabled notification sounds).
The default value is nil which means no sound is played for your notification.
To supply a custom sound, add a .caf
, .wav
, or .aiff
file to your app bundle. Sounds that last longer than 30 seconds are not supported. Supplying a sound that does not meet those requirements will cause the default sound to play (UILocalNotificationDefaultSoundName
).
Objective-C
UILocalNotification *notification = [UILocalNotification new];
notification.soundName = @"nameOfSoundInBundle.wav"; // Use UILocalNotificationDefaultSoundName for the default alert sound
Swift
let notification = UILocalNotification()
notification.soundName = "nameOfSoundInBundle.wav"