Skip to content
This repository has been archived by the owner on Aug 19, 2019. It is now read-only.

MinoLiu/FCM-webpush-demo

Repository files navigation

FCM-webpush-demo

A FCM web push demo

Requirements

Build Setup

# install dependencies
npm install
# after config
# run server on 127.0.0.1:5000
npm start

If you don't have vapidkey, you can generate a new key

const vapidKeys = require('web-push').generateVAPIDKeys();
vapidKeys.publicKey;
vapidKeys.privateKey;

Config setting.js

// After using vapid the GCM_KEY is not important
// if you don't want to use that just comment the webpush.setGCMAPIKey(String(GCM_KEY));
// in webpush.js line 14
exports.GCM_KEY = "<YOUR GCM_KEY HERE>"
exports.vapidPublicKey = "<YOUR VAPID PUBLICKEY HERE>"
exports.vapidPrivateKey = "<YOUR VAPID PRIVATEKEY HERE>"

Config /src/static/main.js line 6

var vapidPublicKey = "<YOUR VAPID PUBLICKEY HERE>";

Config /src/static/manifest.json

"gcm_sender_id": "<YOUR_SENDER_ID>"

Usage for sender.js

It can send notification to all subscribes

node sender.js test_title test_body

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published