feat: PWA push notifications — service worker, VAPID, subscription management
- Add web-push VAPID backend with push_subscriptions table (migration 078) - Backend push module with sendPushToUser/sendPushToRoom helpers - Push routes: GET vapid-key, POST subscribe, DELETE unsubscribe - Trigger push on new chat messages in direct/group rooms - PWA manifest, service worker, and icons (72–512px) - Frontend push lib: SW registration, subscribe/unsubscribe helpers - Push API in api.ts, SW registered in main.tsx - usePushSubscription hook for auto-subscribe on permission grant - PushPermissionRow component in ChatWidget settings view Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -897,6 +897,15 @@ export const api = {
|
||||
req<{ ok: boolean }>('DELETE', `/api/hotels/${slug}/payment-gateways/${id}`),
|
||||
},
|
||||
|
||||
// ── Push notifications ────────────────────────────────────────────────────
|
||||
push: {
|
||||
getVapidKey: () => req<{ publicKey: string | null }>('GET', '/api/push/vapid-key'),
|
||||
subscribe: (sub: { endpoint: string; p256dh: string; auth: string }) =>
|
||||
req<{ ok: boolean }>('POST', '/api/push/subscribe', sub),
|
||||
unsubscribe: (endpoint: string) =>
|
||||
req<{ ok: boolean }>('DELETE', '/api/push/unsubscribe', { endpoint }),
|
||||
},
|
||||
|
||||
// Public widget API (no auth)
|
||||
widget: {
|
||||
getConfig: (slug: string) =>
|
||||
|
||||
Reference in New Issue
Block a user