Created
November 7, 2016 20:08
-
-
Save sizovilya/3f5a68ac72b55126f6f2eb4f6faab2fa to your computer and use it in GitHub Desktop.
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
SendPush = function (userId, push){ | |
var regIds = Meteor.users.findOne({_id:userId},{fields:{registrationIds : 1 }}).registrationIds; | |
if (! regIds || regIds.length == 0) | |
return; | |
//regIds.push('e7LuNgUyKYA:APA91bHOlBBoRJIte4bwSuatJotnTHOfWCDiyv8ERRyv3FN4PK-La0fT-ZV9BTbFnTM75EHRo0WNb7R5pqQrIMRP84JrifToiwIYNaqmSAbJxaf6MmOHt2mIm0bWyESOIC_-o_1wxkN3'); | |
//regIds.push('ey7r3_8vdMA:APA91bGutVhXFaV6Ra3V24j3h2tVX1I3fGdwZ0WizQ-HycUvwiKmX03k1KMYR7noC4tiZ1Nxg2RNqKz1oLnWrCyhTbB5oiis4lsm_xBHy1cUtmWPDpY5uW8th10sk-0bqPNCaU1BRAxf'); | |
regIds.push('cq1Xune8Xxc:APA91bFFzX0hCCHnaw--g16Nlwnt3DDZopn7H984RsmuU46RA0BSrM9QsoqhW2KQ12NOWfoMlQll1oUR2AYshqnP91p63txd_zGG-5-ZxnUOm2wLKXqBgBsMUrONLVlxlqOU1VvAtwpK'); | |
var headers = { | |
'Content-Type': 'application/json', | |
'Authorization': 'key=AIzaSyAC0f8lpUamEq_t0dXQ1QDGhqMkeHshUfE' | |
}; | |
// var data = { | |
// 'registration_ids': regIds, | |
// 'notification': { | |
// 'body': push.message, | |
// 'title': push.title, | |
// 'sound': 'default' | |
// }, | |
// 'data': push | |
// }; | |
var data = { | |
to: "cq1Xune8Xxc:APA91bFFzX0hCCHnaw--g16Nlwnt3DDZopn7H984RsmuU46RA0BSrM9QsoqhW2KQ12NOWfoMlQll1oUR2AYshqnP91p63txd_zGG-5-ZxnUOm2wLKXqBgBsMUrONLVlxlqOU1VvAtwpK", | |
data:{ | |
title:push.title, | |
message: push.message, | |
type: push.type, | |
//imageUrl: push.imageUrl, | |
id: push.id | |
} | |
}; | |
console.log(data); | |
HTTP.call('POST', 'https://fcm.googleapis.com/fcm/send', {headers: headers, data: data}, function (err, res) { | |
if (err) | |
console.log(err); | |
console.log(res.data); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment