I am attempting to do push notifications to my iOS app using FCM but am having problems with the sound. I followed this post and implemented the 'sound' key-value pair accordingly but firebase throw this error. Could anyone advice pls?
Error sending message: { Error: Invalid JSON payload received. Unknown name "sound" at 'message.notification': Cannot find field.
My JSON implementation on cloud functions as follows:
...
return admin.database().ref('/fcmToken/' + userUid).once('value', snapshot => {
const values = snapshot.val()
const fcmToken = values.fcmToken
var message = {
notification: {
body: 'New message(s)',
sound: 'default'
},
token: fcmToken
};
return admin.messaging().send(message)
.then((response) => {
return console.log('Successfully sent message:', response);
})
.catch((error) => {
return console.log('Error sending message:', error);
});
})