Notifications
Browser push notifications alert users when it is their turn or when notable events occur.
Key files
| File | Role |
|---|---|
subscription.js |
Subscribe/unsubscribe logic |
public/sw.js |
Service worker (push handler) |
src/index.js |
Service worker registration |
Subscription flow
- User grants notification permission (prompted after login in
LogInOutButton.js). - Service worker registers at
/sw.js. registration.pushManager.subscribe()with VAPID public key from config (PUSH_VAPID_PUBLIC_KEYinglobal.js).- Subscription object sent to backend via auth query
save_push:
POST {PUSH_API_URL}
{ "query": "save_push", "pars": { "payload": subscription } }
Service worker
Registered on window load in index.js. The service worker handles incoming push events and displays notifications even when the tab is in the background.
Backend delivery: Notifications.