I am using cloud functions (node.js) to send notifications to devices. I have my payload set up like this:
const payload = {
notification: {
title: payloadSender,
body: payloadMessage,
},
data: {
chatId: chatId,
},
android: {
priority: 'normal',
collapse_key: chatId,
//todo how to set badge?
notification: {
sound: 'messageSent.wav',
},
},
apns: {
headers: {
'apns-priority': '5',
'apns-collapse-id': chatId,
},
payload: {
aps: {
badge: newUnreads,
sound: 'messageSent.wav',
'content-available': 1,
}
}
}
};
According to the Firebase docs, you can use the "android" and "apns" fields for device specific behavior. Below is the JSON representation found here for a Message sent by FCM:
{
"name": string,
"data": {
string: string,
...
},
"notification": {
object(Notification)
},
"android": {
object(AndroidConfig)
},
"webpush": {
object(WebpushConfig)
},
"apns": {
object(ApnsConfig)
},
// Union field target can be only one of the following:
"token": string,
"topic": string,
"condition": string
// End of list of possible types for union field target.
}
Why am I getting the error Messaging payload contains an invalid "android" property. Valid properties are "data" and "notification".
And Messaging payload contains an invalid "apns" property. Valid properties are "data" and "notification".
?