Overview
Zen Nurture uses the Web Push protocol to deliver reminder notifications to users’ devices. This API allows you to manage push subscriptions and send notifications.Push Subscription Schema
Subscribe to Push Notifications
Register a device for push notifications.Parameters
Push service endpoint URL
Encryption keys for the subscription
Response
The subscription ID (creates new or updates existing based on endpoint)
If a subscription with the same endpoint already exists, it will be updated with the new keys instead of creating a duplicate.
Unsubscribe from Push
Remove a push subscription.Parameters
The push endpoint to unsubscribe
List My Subscriptions
Retrieve all push subscriptions for the authenticated user.Response
Array of push subscription objects for the current user
List Family Subscriptions
Retrieve all push subscriptions for members of a family.Parameters
The family ID
Response
Array of all push subscription objects for family members
This is useful for sending notifications to all caregivers in a family.
VAPID Keys Setup
VAPID (Voluntary Application Server Identification) keys are required for Web Push.Service Worker Setup
Register a service worker to handle push notifications.public/sw.js
app/layout.tsx
Cron-Based Reminder Delivery
Zen Nurture uses a cron job to check for due reminders and send push notifications.Cron Setup
convex/crons.ts
How It Works
Send push notifications
For each due reminder, send push notifications to all subscribed family members.
Notification Payload
Push notifications sent by Zen Nurture have this structure:Notification title (usually reminder title)
Notification body (includes baby name and context)
Unique tag to group/replace notifications
Deep link URL to open when notification is clicked
Browser Support
- Supported
- Not Supported
Browsers with full Web Push support:
- Chrome 50+ (Desktop & Android)
- Firefox 44+ (Desktop & Android)
- Edge 17+
- Opera 37+
- Samsung Internet 4+
Best Practices
Request permission at the right time
Request permission at the right time
Don’t ask for notification permission immediately on page load. Wait until the user performs an action that benefits from notifications (e.g., creating a reminder).
Handle permission denial gracefully
Handle permission denial gracefully
If the user denies permission, provide alternative notification methods (email, SMS) or in-app alerts.
Test on multiple devices
Test on multiple devices
Push notifications behave differently across browsers and operating systems. Test thoroughly.
Keep VAPID keys secure
Keep VAPID keys secure
Never expose your private VAPID key in client code. Store it securely in environment variables.
Handle expired subscriptions
Handle expired subscriptions
Push endpoints can expire. Your cron job should automatically remove failed subscriptions.
Use meaningful notification content
Use meaningful notification content
Include the baby’s name and specific action in the notification body for clarity.
Troubleshooting
Notifications not appearing
Notifications not appearing
Check these common issues:
- Browser notification permission granted?
- Service worker registered successfully?
- VAPID keys configured correctly?
- Device online and not in “Do Not Disturb” mode?
Subscription fails
Subscription fails
Possible causes:
- Invalid VAPID public key format
- Service worker not registered
- Browser doesn’t support push (check Browser Support tab)
Push endpoint expired
Push endpoint expired
Solution:
Push endpoints can expire. Implement logic to re-subscribe when subscription.expirationTime is near or when pushManager.getSubscription() returns null.
Related Resources
Reminders
Create reminder rules that trigger push notifications
Reminders Guide
Feature guide for smart reminders
Web Push Spec
Official Web Push API specification
web-push Library
Node.js library for sending push notifications
