I want to add the push notification thing using FCM in Node.js .For that I tried this
My nodejs code
var FCM = require('fcm-node');
var serverkey = 'SERVERKEY';
var fcm = new FCM(serverkey);
var message = {
to : req.body.userToken,
collapse_key : 'XXX',
data : {
my_key: 'my value', contents: "abcv/"
},
notification : {
title : 'Title of the notification',
body : 'Body of the notification'
}
};
fcm.send(message, function(err,response){
if(err) {
console.log(message);
console.log("Something has gone wrong !");
} else {
console.log("Successfully sent with resposne :",response);
}
});
Whenever I try to run this code and start my server,I get this error in the console always.
/var/www/html/chatApp/node_modules/fcm-node/lib/fcm.js:10
function FCM(accountKey, proxy_url=null) {
^
SyntaxError: Unexpected token =
at Module._compile (module.js:439:25)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/var/www/html/chatApp/node_modules/fcm-node/index.js:1:80)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
Can anybody please explain what I'm doing wrong?