How to create android notification channel with custom sound - infobip/mobile-messaging-react-native-plugin GitHub Wiki

Create a custom notification channel with custom sound for Android

To enable custom sound for notifications, you need to create a custom notification channel. This is done by adding notificationChannelId, notificationChannelName and notificationSound as part of Android configuration in the MobileMessaging.init method. Note that all three fields must be provided; null or empty strings won't be accepted.

MobileMessaging.init({
    applicationCode: APP_CODE,
    android: {
        notificationChannelId: "test-channel-id",
        notificationChannelName: "Test Channel Name",
        notificationSound: "my_sound"
    }
});

For more about Android notification channels, read Android Developers - Notification Channels

This will create a new custom notification channel with a given notificationChannelId and a notificationChannelName. It will also set the custom sound for notifications. The sound file should be placed in the Android res/raw directory of your project.

Add a 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.

Why don't I hear my custom sound?

MobileMessaging SDK builds a notification in the notification center by using default device sound. Default sound is played if:

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

Sound will not be played if:

  • sound file name targeted by the API is invalid (valid name: my_sound.wav)
  • sound file is not valid, e.g., the file has a wrong extension

NOTE: Prerequisite for playing any sound is that the sound is enabled for both, a device and your application.