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

https://github.com/domfarolino/push-notifications

Progressive Web App demonstrating push notifications with encrypted payload
https://github.com/domfarolino/push-notifications

encrypted-payloads nodejs notifications push-notifications web-push

Last synced: 9 months ago
JSON representation

Progressive Web App demonstrating push notifications with encrypted payload

Awesome Lists containing this project

README

          

# push-notifications

[![MIT license](http://img.shields.io/badge/license-MIT-brightgreen.svg)](http://opensource.org/licenses/MIT)



This app demonstrates the [web-push-libs/web-push](https://github.com/web-push-libs/web-push) NodeJS
library which facilitates sending web push notifications with encrypted payloads via a custom backend.

# Demo

Demo the live application [here](https://domfarolino.com/push-notifications)

# Getting started

## Client

The client-side app is a simple static site rooted at [`docs/`](./docs). The
reason the site lives in the `docs/` folder is because GitHub pages only allows
you to serve static pages from the root or `docs/` folder — custom folders like
`frontend/` or `client/` are not supported.

## Server

```sh
git clone git@github.com:domfarolino/push-notifications.git
cp .env.example .env # Copy environment variable structure
npm install
npm start # Run the server
```

To run the *server* locally you must export the necessary environment variables.
Environment variables should appear in the `.env` file, and below is an
explanation of what each variables is used for:

- `PORT`: Defines the port on which the server will run.
- `VAPID_PUBLIC_KEY`: Defines the public key generated via `node web-push generate-vapid-keys`
- `VAPID_PRIVATE_KEY`: Defines the private key generated via `node web-push generate-vapid-keys`
- `MONGO_URL`: Push notification credentials generated by the client are persisted in MongoDB. Use your mongo URL to save client-generated credentials.
- `API_KEY`: Used to secure some routes local to this application, such as `/credentials`.

When running the server locally, be sure to update `this.backendURL` in
[`docs/js/main.js`](docs/js/main.js) to point to your local server.

# Push Notification Screenshots

## Chrome

![chromeNotif](./chromeNotif.png)

## Firefox

![ffNotif](./ffNotif.png)