jlcvp / fcm-node

A Node.JS simple interface to Google's Firebase Cloud Messaging (FCM) for Android & iOS & Web Notification and data push
MIT License
125 stars 46 forks source link

fcm.send's callback is called twice #50

Closed uropsm closed 4 years ago

uropsm commented 5 years ago

fcm.send's callback is called twice. please help!

fcm.send(message, function(err, response){ if(err) { console.log("Something has gone wrong!") } else { console.log("Successfully sent with response: ", response) << called twice! } })

uropsm commented 5 years ago

in fcm.js, It looks that this part causes this issue.

res.on('end', respond); res.on('close', respond);

sanjeevgehlot008 commented 4 years ago

Same issue Please help !

response: { "message": "Point send successfully" } // calling twice

if (err) {
        var data = {
          status: "false",
          response: { "message": "Notification not send successfully" }
        };

        res.json(data);
} else {
        var data = {
          status: "true",
          response: { "message": "Point send successfully" } // calling twice
        };

            res.json(data);
}
cesardmoro commented 4 years ago

Fixed on this pr https://github.com/jlcvp/fcm-node/pull/52