Skip to content

How to use custom notification sound?

Andrey Kadochnikov edited this page Aug 14, 2018 · 6 revisions

For playing custom sounds, make sure you have sound file in your application project to be able to target it by sending a message.

Check the cases when your custom sound won't be played.

Add sound file to the application project

Place custom sound files in your app bundle (e.g. drag & drop file in XCode) or in the Library/Sounds folder of your app's container directory (if the folder does not exist, create it).

Apple's official docs on how to prepare a sound file.

You should provide .sound option as userNotificationType parameter while integrating your app with Mobile Messaging SDK.

Send message

In order for custom notification sound to be played by the OS, you need to send message by API with the name of the sound (with extension) by using soundName parameter in notificationOptions.

Why don't I hear my custom sound?

IOS notifications are delivered along with playing the default alert sound. Default sound is played if:

  • custom sound name isn't set in send message API request
  • sound file targeted by API is not found by the provided name (e.g. valid name: my_sound.wav, e.g. invalid name: my_sound)
  • sound file is not valid - cannot be longer than 30 seconds or is of wrong extension (supported file formats: .wav .aiff .caf)

NOTE: Prerequisite for playing any sound is that sound is enabled for device and for your application.

Clone this wiki locally