Day 5 Sending Firebase Notification using Nodejs

by Start Bootstrap


Posted on Nov 01, 2017


Once you're setup with the firebase in your application, you can send push notification through any source, I am using Nodejs.

Step 1 : Install FCM in node project Go here https://www.npmjs.com/package/fcm or add

From your terminal

npm install fcm

Step 2 : Include fcm in your controller

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

Step 3 : Configure fcm in your project 

var fcm = new FCM(serverKey);

Step 4 : Trigger / Push the push notification

var message = {
        to: fcm_token
        collapse_key: pid,
        notification: {
            title: "title",
            body: message
        }
    };
fcm.send(message, function(err, response) {
        if (err) {
            console.log("Something has gone wrong!");
        } else {
            console.log("Successfully sent with response: ", response);
        }
    });

 Now you're done ! 


Search
Side Widget
You can put anything you want inside of these side widgets. They are easy to use, and feature the new Bootstrap 4 card containers!