Skip to content

Latest commit

 

History

History
60 lines (44 loc) · 1.53 KB

README.md

File metadata and controls

60 lines (44 loc) · 1.53 KB

fcm-node

A Node.JS simple interface to Google's Firebase Cloud Messaging (FCM)

Installation

Via npm:

$ npm install fcm-push

Usage

var FCM = require('fcm-push');

var serverKey = '';
var fcm = new FCM(serverKey);

var message = {
    to: 'registration_token', 
    collapse_key: 'your_collapse_key', 
    data: {
        your_custom_data_key: 'your_custom_data_value'
    },
    notification: {
        title: 'Title of your push notification',
        body: 'Body of your push notification',
        icon: 'ic_launcher' //now required
    }
};

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

See FCM documentation for details.

Credits

Extended by Leonardo Pereira. Based on the great work on fcm-push by Rasmunandar Rustam cloned and modified from there, which in its turn, was cloned and modified from Changshin Lee's node-gcm

License

GNU LESSER GENERAL PUBLIC LICENSE v3

Changelog

1.0 forked from fcm-push and implemented topic messages return codes