# Push Notifications - Quick Start ## 🚀 5-Minute Setup ### 1. Install & Generate Keys ```bash npm install npm run vapid:generate ``` ### 2. Add Keys to .env ```env VAPID_PUBLIC_KEY= VAPID_PRIVATE_KEY= VAPID_SUBJECT=mailto:your-email@example.com ``` ### 3. Update Database ```bash npx prisma db push ``` ### 4. Add to Profile Page ```typescript // app/profile/page.tsx import NotificationSettings from '@/components/NotificationSettings'; // Add to your page ``` ### 5. Send Notifications ```typescript // In your action files import { notifyItemAdded } from '@/lib/notification-helpers'; // After creating an item: await notifyItemAdded(listId, item.title, session.user.id); ``` ## ✅ Done! Users can now: - Enable notifications in their profile - Receive push notifications on all their devices - Get notified about list activity even when the app is closed ## 📱 iOS Support For iOS notifications: 1. Deploy with HTTPS 2. User must "Add to Home Screen" 3. Requires iOS 16.4+ ## 🔧 Available Notification Functions ```typescript // Item notifications notifyItemAdded(listId, itemTitle, userId) notifyItemRemoved(listId, itemTitle, userId) notifyItemCompleted(listId, itemTitle, userId) // Invitation notifications notifyListInvitation(invitationId, email) notifyInvitationAccepted(invitationId) // Collaboration notifications notifyRemovedFromList(userId, listTitle, removedByUserId) ``` ## 📚 Full Documentation - **PUSH_NOTIFICATIONS_SETUP.md** - Complete setup guide - **PUSH_NOTIFICATIONS_INTEGRATION_EXAMPLE.md** - Code examples - **PUSH_NOTIFICATIONS_GUIDE.md** - Architecture & testing ## 🎯 Key Features - ✅ Self-hosted (no external services) - ✅ Works on iOS, Android, Desktop - ✅ Multiple devices per user - ✅ Automatic subscription cleanup - ✅ Non-blocking (won't slow down your app)