Skip to content

Instantly share code, notes, and snippets.

@ans-4175
Last active July 2, 2016 01:51
Show Gist options
  • Save ans-4175/6b264f7de11983ccbde601e0727b2047 to your computer and use it in GitHub Desktop.
Save ans-4175/6b264f7de11983ccbde601e0727b2047 to your computer and use it in GitHub Desktop.
Example Using of fcm-push-notif modules https://github.com/eFishery/fcm-push-notif
var FCM = require('fcm-push-notif');
var serverKey = 'firebase_server_key';
var fcm = new FCM(serverKey);
var message = {
to: '/topics/news', // required could be topic url or device registration token
collapse_key: 'your_collapse_key',
data: {
message: 'This is data message'
},
notification: {
title: 'Test',
body: 'test message'
}
};
fcm.send(message)
.then(function(response){
console.log("Successfully sent with response: ", response);
})
.catch(function(err){
console.log("Something has gone wrong!");
console.error(err);
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment