https://github.com/perty/service-worker-test
An example of using Service Worker and Notifications.
https://github.com/perty/service-worker-test
Last synced: 2 months ago
JSON representation
An example of using Service Worker and Notifications.
- Host: GitHub
- URL: https://github.com/perty/service-worker-test
- Owner: perty
- Created: 2023-05-20T13:48:44.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2023-05-21T15:13:18.000Z (about 3 years ago)
- Last Synced: 2025-01-18T18:39:05.354Z (over 1 year ago)
- Language: JavaScript
- Size: 6.84 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: ReadMe.md
Awesome Lists containing this project
README
# Service worker test
This is for me learning about service workers and notifications.
The goal is to have a local environment where I can try service worker related things, notifications in particular.
I like to write as many notes as possible to keep my learnings.
## A local server with https
Service workers are only available when using https, one reason being that they can intercept network traffic.
### Certificate
So the first thing is to set up a server that serves pages by https. To do that, we first need a certificate. I opted for [mkcert](https://github.com/FiloSottile/mkcert#installation).
There is an installation file for Mac using brew: `installt-mkcert.sh`.
Then head to the `cert` folder and run `cert-here.sh`. This will create necessary files for the server.
### Server
To run a server, there are several options, [http-server](https://www.npmjs.com/package/http-server) being a very simple one.
Start the server with `start-server.sh`. The page should show up on [https://localhost:8080](https://localhost:8080).
## Notifications
Not as easy as it seemed when I started to look at it. A great promise by PWA to be able to send notifications. But wait, some notifications are local and some are remote. And the remote ones, initiated from the server, requires the push API.