Is there any way to send notifications from FCM from a node.js server?
I haven\'t found anything about it inside documentation.
//I done by this code using node- gcm module.
//We're using the express framework and the node-gcm wrapper
var express = require('express');
var gcm = require('node-gcm');
//init express
var app = express();
app.get('/push', function (req, res) {
var message = new gcm.Message({
data: { key1: 'hello' },
notification: {
title: 'SPECOZ Offers1',
body: 'body_data'
}
});
// Set up the sender with you API key, prepare your recipients' registration tokens.
var sender = new gcm.Sender('Api_Key');
sender.send(message, 'device_token', function (err, response) {
if (err) {
console.error("Error:", err);
}
else console.log("Response:", response);
res.send(response);
});
});
app.listen("pass the port number");