Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Node.js request sending downstream POST with Google Firebase Cloud Message
Example of Node.JS to send downstream cloud message with Firebase
NPM package request is needed in this code gist
// Firebase auth key
var serverKey = "Firebase Server Key";
var clientToken= "Client Device Token"
// Payload message data
var deviceId = req.query.deviceId;
var eventName = req.query.eventName;
var value = req.query.value;
var options = {
url: '',
headers: {
'Authorization': 'key=' + serverKey
json: {
"to": clientToken,
"data": {
deviceId: deviceId,
eventName: eventName,
value: value
};, function optionalCallback(err, httpResponse, body) {
if (err) {
return console.error('ERROR - FIREBASE POST failed:', err);
// Success
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment