forked from javajuice1337/push-receiver-v2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
40 lines (35 loc) · 894 Bytes
/
index.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
38
39
40
// Note: The send endpoint is deprecated and removed as of June 20, 2024: https://firebase.google.com/support/faq#fcm-depr-features
const request = require('request-promise');
const argv = require('yargs').argv;
const serverKey = argv.serverKey;
const token = argv.token;
if (!serverKey) {
console.error('Missing serverKey argument');
return;
}
if (!token) {
console.error('Missing token argument');
return;
}
(async () => {
try {
const response = await request({
method : 'POST',
url : 'https://fcm.googleapis.com/fcm/send',
json : true,
body : {
to : token,
notification : {
title : 'Hello world',
body : 'Test',
},
},
headers : {
Authorization : `key=${serverKey}`,
},
});
console.log(response);
} catch (e) {
console.error(e.message);
}
})();