Skip to content

How to use custom notification sound?

Olga Koroleva edited this page Mar 11, 2021 · 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 project in res/raw directory. If the folder does not exist, create it. Make sure that your file is in one of the supported audio formats.

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 or without extension) by using soundName parameter in notificationOptions.

Why don't I hear my custom sound?

MM SDK builds notification in notification centre by using default device sound. Default sound is played if:

  • custom sound name isn't set in send message API request

Sound will not be played if:

  • sound file targeted by API is not found by the provided name (valid name: my_sound.wav)
  • sound file is not valid - file is of wrong extension

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

Clone this wiki locally