An open API service indexing awesome lists of open source software.

https://github.com/toumash/webpush-demo

Simple demo showing an implementation sample of web-push with nodejs
https://github.com/toumash/webpush-demo

demo nodejs web-push-notification

Last synced: about 1 month ago
JSON representation

Simple demo showing an implementation sample of web-push with nodejs

Awesome Lists containing this project

README

          

# Web Push Demo

## Wymagania

- Zainstalowany nodejs

# How to run?

```
npm install
node ./generate-vapid.js # copy these keys to server.js and index.html
node ./server.js
```

## Jak to działa?
1. Wygeneruj klucze VAPID

```shell
node ./vapidkey-generator.js
```

2. Rejestracja service workera

Następuje po wejściu na stronę przez użytkownika. Service worker to javascript chodzący w tle nawet po zamknięciu karty.

```js
var sw = await navigator.serviceWorker.register("./sw.js");
console.log("service worker registered!", sw);
```

3. Użytkownik zgadza się na subscrypcję

```js
var sw = await navigator.serviceWorker.ready;
var pushInfo = await sw.pushManager.subscribe({
userVisibleOnly: true,
applicationServerKey:
"