Created
December 23, 2017 09:05
-
-
Save n1lesh/75c3f5549540bd81a680ce222e91912b to your computer and use it in GitHub Desktop.
Firebase Cloud Messaging with Node.js - FCM 3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const sendNotifications = (data) => { | |
const dataString = JSON.stringify(data) | |
const headers = { | |
'Authorization': 'key=<your firebase legacy server key>', | |
'Content-Type': 'application/json', | |
'Content-Length': dataString.length | |
} | |
const options = { | |
uri: 'https://fcm.googleapis.com/fcm/send', | |
method: 'POST', | |
headers: headers, | |
json: data | |
} | |
request(options, function (err, res, body) { | |
if (err) throw err | |
else console.log(body) | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment