Day 5 Sending Firebase Notification using Nodejs

1509494400000 Andriod

by Start Bootstrap


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 ! 


Blog Search
Tags
  • Sysaxiom (4)
  • Github (8)
  • Windows (1)
  • php (25)
  • General Tips (0)
  • GoogleMaps (2)
  • Google App Script (1)
  • Heroku (4)
  • Laravel Middleware (1)
  • xampp (1)
  • Terminal (1)
  • TechCrunch (1)
  • Ubuntu (3)
  • MySQL (2)
Side Widget
can put anything you want inside of these side widgets. They are easy to use, and feature the new Bootstrap 4 card containers!