Skip to content

Instantly share code, notes, and snippets.

@ikishanoza
Last active October 4, 2018 11:38
Show Gist options
  • Save ikishanoza/9371bce78f12eb0749fef7accd9f46d0 to your computer and use it in GitHub Desktop.
Save ikishanoza/9371bce78f12eb0749fef7accd9f46d0 to your computer and use it in GitHub Desktop.
NodeJs script for Sending push notification using fcm
/*
* 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