JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 13606
  • Score
    100M100P100Q130040F
  • License GNU LGPLv3

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

Package Exports

  • fcm-node

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (fcm-node) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

fcm-node

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

Installation

Via npm:

$ npm install fcm-node

Usage

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

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

var message = { //this may vary according to the message type (single recipient, multicast, topic, et cetera)
    to: 'registration_token', 
    collapse_key: 'your_collapse_key',
    
    notification: {
        title: 'Title of your push notification', 
        body: 'Body of your push notification' 
    },
    
    data: {  //you can send only notification or only data(or include both)
        my_key: 'my value',
        my_another_key: 'my another value'
    }
};

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.8 - <FIX> 'icon' field no longer required in notification 1.0.7 - renaming repository
1.0.6 - bugfix: send function was always returning an error object for multicast messages (multiple registration ids)
1.0.5 - bugfix with UTF-8 enconding and chunk-encoded transfers
1.0.1 - forked from fcm-push and extended to accept topic messages without errors