node js push notification android firebase code example
Example 1: fcm-node Error: Invalid payload object at FCM.send
Example 2: node js send fcm
var FCM = require('fcm-node')
var serverKey = require('path/to/privatekey.json')
var fcm = new FCM(serverKey)
var message = {
to: 'registration_token',
collapse_key: 'your_collapse_key',
notification: {
title: 'Title of your push notification',
body: 'Body of your push notification'
},
data: {
my_key: 'my value',
my_another_key: 'my another value'
}
}
fcm.send(message, function(err, response){
if (err) {
console.log("Something has gone wrong!")
} else {
console.log("Successfully sent with response: ", response)
}
})