I am working on a cordova app and using the cordova-fcm plugin to enable push notification on my app. Everything works find, the plugin can retrieve tokens, subscribe to channels and I can send notifications to my device using the FCM HTTP v1 API. The problem is the device does not play any sound! I have tried setting up the payload to "sound":"default" or a custom sound file put in the res/raw directory, but no luck. Now I looked into the source code of the above said plugin and found that onMessageReceived callback does not have the code to forward the notification using notificationManager.notify(). Now I have a confusion here. When I was reading FCM docs, what I understood is that when a message is received in the background or the app is killed, the message is handled by the system and I don't need to do anything with notificationManager.notify(). Do I understand it correct? Also the payload has a "sound" property and it is mentioned in the doc that either I can pass "default" or any custom file name I put in res/raw directory. So how is this handled, I mean which sound needs to be played? Is this handled by the system? Also if I implement notificationManager.notify(), then how do I do setSound() as per the "sound" property in the received payload?
Here is the payload that I have tried...
{
'message': {
"topic": "all",
'notification': {
'title': 'FCM Notification',
'body': 'Notification from FCM',
},
"android": {
"priority": "high",
"notification": {
"sound": "default",
"click_action": "FCM_PLUGIN_ACTIVITY"
}
}
}
}
Never mind. It seems like a problem with my phone. Sound is played on other devices.. I tried to find a setting on my phone to check if sound needs to be enabled for some particular app notifications, but I could not find it either. Just to let the the users know I am using MI Note 5 Pro. If someone else stumble on this issue, this might help.