I want my Cloud Function to send a push notification to a specific topic, which works just fine. However, when I'm adding the "badge" field, the following error occurs:
Unknown name "badge" at 'message.notification': Cannot find field.
What am I supposed to do if I want to specify a badge number for iOS devices? The code I have looks like follows:
exports.onAddLog = functions.database.ref("/NodesLog/{id}").onCreate((change, context) => {
const payload = {
"topic": "Channel123",
"notification": {
"title": "Test-Title",
"body": "Test-Body",
"badge": "1"
},
"data": {
"test": "test",
"notId": "123"
}
}
const promise : Promise<any> = admin.messaging().send(payload)
.catch(error => console.error("Error on send: " + error))
.then(sendSuccess => console.log("Notification send "))
.catch(() => console.error("What happened?"))
return promise;
})