Last active
October 25, 2016 08:30
-
-
Save duynhm/5d6a652a57f95dfdf886a6c02d23b492 to your computer and use it in GitHub Desktop.
FCM
This file contains hidden or 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
{ | |
"to" : "bk3RNwTe3H0:CI2k_HHwgIpoDKCIZvvDMExUdFQ3P1...", | |
"notification" : { | |
"body" : "great match!", | |
"title" : "Portugal vs. Denmark", | |
"icon" : "myicon" | |
} | |
} |
This file contains hidden or 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
https://fcm.googleapis.com/fcm/send | |
Content-Type:application/json | |
Authorization:key=AIzaSyZ-1u...0GBYzPu7Udno5aA | |
{ | |
"to": "/topics/foo-bar", | |
"data": { | |
"message": "This is a Firebase Cloud Messaging Topic Message!", | |
} | |
} | |
//send multi topics | |
https://fcm.googleapis.com/fcm/send | |
Content-Type:application/json | |
Authorization:key=AIzaSyZ-1u...0GBYzPu7Udno5aA | |
{ | |
"condition": "'dogs' in topics || 'cats' in topics", | |
"data": { | |
"message": "This is a Firebase Cloud Messaging Topic Message!", | |
} | |
} | |
//HTTP Response | |
//Success example: | |
{ | |
"message_id": "1023456" | |
} | |
//failure example: | |
{ | |
"error": "TopicsMessageRateExceeded" | |
} |
This file contains hidden or 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
pushNotificationAPPTopic: function (param) { | |
var request = require('request'); | |
var full_url = "https://fcm.googleapis.com/fcm/send"; | |
param = { | |
"to": "/topics/news", | |
"data": { | |
'Subject': param.subject, | |
'Image': param.image, | |
'Content': param.content | |
} | |
}; | |
console.log("url:" + full_url); | |
console.dir(param); | |
request.post({ | |
uri: full_url, | |
body: param, | |
headers: { | |
'content-type': 'application/json', | |
'Authorization': 'key=AIzaSyAVwjj...otJUrI' | |
}, | |
json: true | |
}, function (err, response, body) { | |
if (err) { | |
console.log(err) | |
} else { | |
console.log(body); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment