I am using Firebase push notifications in my iOS Application. Although I am able to send the notification by sending below payload, it doesn't play a sound when received.
{ "to": "myToken", "notification": { "body": "test", "title": "test" }, "priority": "high" "sound": "default" }
If I send the test message from console, it works well and plays notification sound.
Note:
https://fcm.googleapis.com/fcm/send
For Apple client apps, you can receive notification and data payloads up to 4000 bytes over the Firebase Cloud Messaging APNs interface.
On Android devices, it is possible to choose individual push notification sounds.
Send a test notification messageOpen the Notifications composer and select New notification. Enter the message text. Select Send test message. In the field labeled Add an FCM registration token, enter the registration token you obtained in a previous section of this guide.
This could be caused by the unrealistic heartbeat intervals in Firebase Cloud Messaging. FCM works by maintaining an idle socket connection from an Android device to Google's servers.
your JSON "sound" : "default"
should be inside the "notification"
key not in the root of the JSON. This JSON should work.
{ "to": "myToken", "notification": { "body": "test", "title": "test", "sound": "default" }, "priority": "high" }
When using the FCM admin SDK, you have to specify sounds separately for Android and Apple devices:
let message = { notification: { 'body': 'This is the message the user sees', }, data: { 'param1': 'specify some extra data here', }, // Apple specific settings apns: { headers: { 'apns-priority': '10', }, payload: { aps: { sound: 'default', } }, }, android: { priority: 'high', notification: { sound: 'default', } }, token: 'target FCM token goes here', };
(Note: I've only tested the Apple settings thus far)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With