- Install to web app How
- Fake install prompt
- Rich install
- Install & update service worker How
- No page active enter website automatic reload to install & active new service worker
- Have active page, every 10sec detect update & show update banner click to update
- Unregister servic worker
- Parallel precache files
- Notifiaction How
- Catch notification by service worker
- Click notification to open web app or website in browser
- Click notification redirect to
/homepage - Can update installed app unreadCount
- Unsubscribe notification
- Install dependencies
preparewill trigger after install finish, create vapid for notification servicenpm install
- Generate https certs (PWA requirement)
gen:certwill create certs under/certfoldernpm run install:mkcert npm run gen:cert
- Run website on localhost
npm run dev
Another terminalRun servicenotification server, allow user subscribe & send notification
npm run dev:server
- Open website on
https://localhost:5173(default, might change)notification service will run on
https://localhost:8080
- Change branch to
auto-update
https://github.com/sky172839465/pwa-sharing/tree/auto-update
- build website & using
honoas web server & notification servernpm run preview
- Open website on
https://localhost:8080 Another terminalUpdate client code & rebuild website to simulate production update service workernpm run build:dev
- Default target icon for generate is in
pwa-assets.config.js>public/favicon.svg
https://vite-pwa-org.netlify.app/assets-generator/npm run gen:pwa-assets
- Using library or follow framework suggestion to do it (recommend)
- Update strategy
- periodically check service worker changed (recommend)
default browser 24hr check one time better use
swrreact-queryhandle when reconnect or window refocus - automatic update
- prompt for update
- periodically check service worker changed (recommend)
- Parallel precache files
- problem: GoogleChrome/workbox#2880
- implement: https://github.com/sky172839465/pwa-sharing/pull/26/files
- ref
- Prepare vapid
publicKeyprivateKey - Client frontend
- Request notification permission from user
- After permission granted, ask
subscriptionfrom browser service - Send
subscriptionto servicesubscriptionprovide endpoint & keys allow server send request to browser service make a notification - example: https://github.com/sky172839465/pwa-sharing/blob/main/src/client/pages/Notification/useNotification.js
- Client service worker
- Add
pushevent listener to catch notification from browser service and show notification, update web app badge unread count - Add
notificationclickevent listener to close notifiction & redirect to specific web app route
- example: https://github.com/sky172839465/pwa-sharing/blob/main/public/sw.js
- Add
- Server
- Add endpoint to store
subscription - Using
subscriptionendpoint send notification to browser service - example: https://github.com/sky172839465/pwa-sharing/blob/main/src/server/index.js
- Add endpoint to store
- Ref





