-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFCM.js
37 lines (31 loc) · 797 Bytes
/
FCM.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import { HTTP } from 'meteor/http';
if (Meteor.isServer) {
Meteor.methods({
"FCM.push": function (opt) {
let fcmHost = 'https://fcm.googleapis.com/fcm/send';
params = {
headers:
{
"Content-Type":"application/json",
"Authorization":"key=MyAuthorizationKeyFromFCMCloudMessagingSettings123456789"
},
data:
{
"registration_ids":opt.regIDs,
"data":
{
"text":opt.text
}
}
};
HTTP.call( 'POST', fcmHost, params, function( error, response ) {
if ( error ) {
console.log( error );
} else {
console.log(response.content);
console.log( 'Push success send!' );
}
});
}
});
}