Skip to content

Instantly share code, notes, and snippets.

@kiuchikeisuke
Created July 24, 2018 00:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kiuchikeisuke/486abf22cb1d225c74738562005a5444 to your computer and use it in GitHub Desktop.
Save kiuchikeisuke/486abf22cb1d225c74738562005a5444 to your computer and use it in GitHub Desktop.
FCMの対象端末へのプッシュ通知をGAS使って簡単に実現する ref: https://qiita.com/k_keisuke/items/f670d2a3d7f78126f2f5
Const = {
FCMServerKey: "AAAAW1C_znk:APA91bHcG..."
}
function sendNotification(token, value1, value2) {
var data = {
"to": token,
"data":{
"value1": value1, //hogehoge
"value2": value2 //mogemoge
}
}
var auth = "key=" + Const.FCMServerKey;
var headers = {
'Authorization': auth,
"contentType" : "application/json",
};
var options = {
"method" : "post",
"payload" : data,
"headers" : headers,
"muteHttpExceptions": true
};
var url = "https://fcm.googleapis.com/fcm/send";
var res = UrlFetchApp.fetch(url, options);
Logger.log(res);
return res;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment