- Service worker + Web Push API for browser/mobile notifications - PWA manifest with icons for home screen install (iOS 16.4+) - Push subscription management (subscribe/unsubscribe API routes) - Notification toggle in Settings > General - Push scheduler script (cron) checks cached events and sends notifications at reminder times, with dedup tracking - Test notification endpoint at /api/push/test - Persists reminders in calendar event cache for scheduler access - New DB models: PushSubscription, SentNotification - New user field: notificationsEnabled Setup: generate VAPID keys with `npx tsx scripts/generate-vapid-keys.ts` and add to .env, then run scheduler via cron every minute. v1.37.0
10 lines
346 B
TypeScript
10 lines
346 B
TypeScript
#!/usr/bin/env npx tsx
|
|
import webpush from 'web-push';
|
|
|
|
const vapidKeys = webpush.generateVAPIDKeys();
|
|
|
|
console.log('Add these to your .env file:\n');
|
|
console.log(`NEXT_PUBLIC_VAPID_PUBLIC_KEY=${vapidKeys.publicKey}`);
|
|
console.log(`VAPID_PRIVATE_KEY=${vapidKeys.privateKey}`);
|
|
console.log(`VAPID_SUBJECT=mailto:admin@todo.martin-bierschenk.de`);
|