I am using Firebase push notifications in my Android App. I can send correctly notification with custom icon, but I have not managed to play my custom sound. I always get the default sound of my device.
{
"registration_ids": "myToken",
"notification": {
"body": "my body",
"title": "my title",
"icon": "ic_notification",
"sound": "mysound.mp3" // I tried "mysound", "mysound.wav"...
},
"priority": "high"
}
The custom sound is located in /res/raw
I have been able to play my custom sound with onMessageReceived
and Firebase data message but not with Firebase notification message.
My android device is Xiaomi Mi A1 and Oreo 8.1., also tried with Xiaomi Mi A2 with same result.
I tried with php and curl, with node.js... always same problem, I get my default sound.
UPDATE
With this code for node.js does not work either:
var registrationToken = 'xxxxxx';
var message = {
notification: {
title: 'my title',
body: 'my body',
},
android: {
ttl: 3600 * 1000,
notification: {
color: '#ff0000',
sound: 'mysound.mp3'
}
},
token: registrationToken
};
notification
is{ "body", "payload" }
. Structure other settings in the platform specific sections (e.g. for sound, place the sound inmessage.android.notification.sound
) – James Poag