diff --git a/PushMessageFromServer.js b/PushMessageFromServer.js index 4f9904f..83f44ce 100644 --- a/PushMessageFromServer.js +++ b/PushMessageFromServer.js @@ -2,6 +2,7 @@ // https://felixgerschau.com/web-push-notifications-tutorial/ // https://developers.google.com/web/fundamentals/codelabs/push-notifications const webPush = require('web-push'); +const pushSubscription = require('./pushSubscription.json') // VAPID keys should be generated only once with: // const vapidKeys = webPush.generateVAPIDKeys(); @@ -18,16 +19,7 @@ webPush.setVapidDetails( vapidKeys.privateKey ); -// This is an sample subscription object that we get after subscript on browser -const pushSubscription = -{ - "endpoint": "", - "expirationTime": null, - "keys": { - "p256dh": "", - "auth": "" - } -} +// pushSubscription is an sample subscription object that we get after subscript on browser const payload = { title: `Hello at ${(new Date()).toISOString()}`, diff --git a/README.md b/README.md index 6b65b6f..e00e809 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ # Send push notification from a server -- Set a push subscription object that we get after a user's subscribed web push in `PushMessageFromServer.js` +- Set a push subscription object that we get after a user's subscribed web push in `pushSubscription.json` - Then execute the following command: ```sh $ node PushMessageFromServer.js diff --git a/pushSubscription.json b/pushSubscription.json new file mode 100644 index 0000000..47c33c6 --- /dev/null +++ b/pushSubscription.json @@ -0,0 +1,8 @@ +{ + "endpoint": "https://fcm.googleapis.com/fcm/send/dDEsIVpevRQ:APA91bFG6umABbc7IVuCQqc2TNx0Ramrnm0hnLr7CWsgr52AeJh7OPwOUoLMrv3sK8WmwEgsfpgH3kXrEKzOj5fMG5cWpFd_ZyocQhqe6Gt5vy1cPXEPe01grF1IL-bqxQRVDqhm-6e-", + "expirationTime": null, + "keys": { + "p256dh": "BC_wvLFfABtfoqusJKwsNqJAyDz-rIvAIg9YfB_z7lemXNFkzBLeLd9PTKGbeQTTflYqLZvIiT-lZHsA7BHZUDo", + "auth": "LigA_xph0Wlygf0WkYq_gA" + } +} \ No newline at end of file