-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpush.js
31 lines (27 loc) · 958 Bytes
/
push.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
var webPush = require('web-push');
const vapidKeys = {
"publicKey": "BCUP1YCSf-AzRmjq4--cttXC9jDeQI4CP87v4vteglbZUyfSaWwEz2m2mNM7a5LH2VbvWgQxuNQbQ4qn14wKkDE",
"privateKey": "daERNCg_u6U81O0xGc-OnTguGuIlSmKqLVWGmzRZVj8"
};
webPush.setVapidDetails(
vapidKeys.publicKey,
vapidKeys.privateKey
)
var pushSubscription = {
"endpoint": "https://fcm.googleapis.com/fcm/send/fwr8x-hEOtQ:APA91bHraegPz7xT6GmmRNsMMrphuJxA8cRREvyIW28I2JX3oBenQKVOGZ3ZCJNeh0kjG6yfPw8fggwDa6SlSTiAOnXF3hJJ4858HY96IAS5QhCYS458vZBWOphGigJoyMk8Q1hidcUH",
"keys": {
"p256dh": "BLa6XQErM4BZUd5HWPb3UPnbKMBye5QN96boqjL0iEMZVL17s+18xuUjL+q+7CQvXe2geRUpYVtNuHeSArssdZc=",
"auth": "3yC/Wg2sCc/6XwQmFB7nhg=="
}
};
var payload = 'Selamat! Aplikasi Anda sudah dapat menerima push notifikasi!';
var options = {
gcmAPIKey: '133596126775',
TTL: 60
};
webPush.sendNotification(
pushSubscription,
payload,
options
);