54 lines
1.6 KiB
Markdown
54 lines
1.6 KiB
Markdown
---
|
|
id: task-3
|
|
title: Add push notifications
|
|
status: Done
|
|
assignee: []
|
|
created_date: '2025-12-15 19:37'
|
|
updated_date: '2026-01-02 14:27'
|
|
labels: []
|
|
dependencies: []
|
|
priority: medium
|
|
---
|
|
|
|
## Description
|
|
|
|
<!-- SECTION:DESCRIPTION:BEGIN -->
|
|
Implement web push notifications for friend arrivals, proximity alerts, and group activity. Include battery-friendly polling options.
|
|
<!-- SECTION:DESCRIPTION:END -->
|
|
|
|
## Implementation Notes
|
|
|
|
<!-- SECTION:NOTES:BEGIN -->
|
|
## Implementation
|
|
|
|
Implemented comprehensive push notification system:
|
|
|
|
1. **Web Push with VAPID** (`sync-server/server.js`)
|
|
- VAPID key authentication for secure push
|
|
- Push subscriptions stored per room
|
|
- Silent push for location requests
|
|
- Notification push for friend joins/meeting points
|
|
|
|
2. **Service Worker** (`public/sw.js`)
|
|
- Handles push events
|
|
- Silent push triggers location update via postMessage
|
|
- Notification push shows native notifications
|
|
- Click handling opens room URL
|
|
|
|
3. **Push Hooks** (`src/hooks/usePushNotifications.ts`)
|
|
- Subscribe/unsubscribe to push notifications
|
|
- Auto-subscribes when joining room
|
|
- Handles VAPID public key fetching
|
|
|
|
4. **Location Request System**
|
|
- "Ping all" button with bell icon in friends list header
|
|
- Individual ping button per participant
|
|
- Deduplicates by name (only pings one session per user)
|
|
- WebSocket for online clients, push for offline
|
|
|
|
5. **Background Location Sync**
|
|
- Automatic periodic location requests (60s interval)
|
|
- Service worker messages for location sync
|
|
- Background Sync API integration
|
|
<!-- SECTION:NOTES:END -->
|