-
Notifications
You must be signed in to change notification settings - Fork 19
How to use custom notification sound?
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.
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.
Use .withCustomNotificationChannel() method with your channel name and channel id:
MobileMessaging.Builder(application)
.withCustomNotificationChannel("your-channel-id", "Your Channel Name", "your-audio-file")
.withDisplayNotification(NotificationSettings.Builder(this)
.withMultipleNotifications()
.build())
.build()expand to see Java code
```java new MobileMessaging.Builder(this) .withCustomNotificationChannel("your-channel-id", "Your Channel Name", "your-audio-file") .withDisplayNotification(new NotificationSettings.Builder(this) .withMultipleNotifications() .build()) .build(); ```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, or Portal by filling Sound name field in Advanced Settings -> Notification Settings -> Standard -> Play Sound on Device .
MM SDK builds notification in notification centre by using default device sound. Default sound is played if:
- custom sound name isn't set
Sound will not be played if:
- sound file 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.
If you have any questions or suggestions, feel free to send an email to support@infobip.com or create an issue.