I have configured remote notifications, and everything is working as expected. Now I want to set a custom sound to my remote notifications. I have tried many ways but these are not working. I am using react-native-push-notification and react-native-firebase.
I have placed a custom sound file in android/app/src/main/res/raw/sound.mp3.
I have also tried soundName:"sound.mp3"
I appreciate any help in this regard. Thanks. :)
Below is the sample Code:
PushNotification.configure({
onRegister: async function(token) {
},
onNotification: function(notification) {
console.log(notification);
},
senderID: 'xxxx',
permissions: {
alert: true,
badge: true,
sound: true,
},
playSound: true,
soundName: 'sound.mp3',
popInitialNotification: true,
requestPermissions: true,
});
}````
For android you must provide a channel id with channelId: "your-channel-id", if the channel doesn't exist the notification might not be triggered.
NOTE: Without channel, notifications might not work
In the soundName option you put your custom sound name for this channel (for default sound, use 'default'), and use the channel Id when sending a notification