Last active
October 4, 2018 11:38
-
-
Save ikishanoza/9371bce78f12eb0749fef7accd9f46d0 to your computer and use it in GitHub Desktop.
NodeJs script for Sending push notification using fcm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* NodeJs script for Sending push notification using fcm | |
*/ | |
// Note : you must be install fcm-node by using command `npm install fcm-node` and then run the script using `node fcm-node.js` | |
const FCM = require('fcm-node'); | |
// Replace these with your own values. | |
const apiKey = 'api-key-here'; | |
const deviceID = 'device-token-here'; | |
const fcm = new FCM(apiKey); | |
const message = { | |
to: deviceID, | |
data: { | |
title: 'Force Start', | |
message: 'This notification should restart the app' | |
} | |
}; | |
fcm.send(message, (err, response) => { | |
if (err) { | |
console.log(err); | |
console.log('Something has gone wrong!'); | |
} else { | |
console.log('Successfully sent with response: ', response); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment