Create Custom Notification Sound

Scheduling notification we have the option to modify the sound of our notification. However, there is one restriction.

Creating notification content there is a field called .sound. If the device isn’t muted it’ll be the sound of an incoming notification. The only restriction is that it can’t be longer than 30 seconds. If so, the system plays the default sound.

I hope you don’t try to cheat Apple with any kind of silent sound, Apple doesn’t like it.

First thing, you need to put the audio file inside your project.

For example:

Scheduling local notification you need to set an instance of UNNotificationSound to sound field.

let content = UNMutableNotificationContent() // notification content object
sound = UNNotificationSound(named: UNNotificationSoundName(rawValue: “notification.mp3”))
// … the rest of notification content

The filename has to match any audio file from the app. If there won’t be any audio file with this name, then default sound will be played.

It works the same with Push Notification. Add sound property inside “aps” and you’ll get a notification with sound.

“aps” : {
// … the rest of push notification
“sound” : “notification.mp3”,
// … the rest of push notification