# Push Notifications Setup

This guide explains how to finish push notifications for PRÓTA House after the PWA is installed.

## What is already done

- PWA install support is in place
- The service worker can display push notifications
- The install page has a button to enable notifications
- The browser permission prompt is wired up on the frontend

## What still needs to be built

To actually send notifications to members, you need a backend that can:

1. Receive and store push subscriptions
2. Send push messages later
3. Handle event reminders, prayer alerts, and program announcements

## What I need from you

Before I can finish the send side, I need:

1. Where you want to host the backend:
   - Netlify Functions
   - Node/Express server
   - Another serverless provider
2. Whether you want one notification list or different lists:
   - All members
   - Leaders only
   - Youth only
   - Event subscribers only
3. The church message format you want:
   - Title
   - Body
   - Link target

## Recommended backend shape

For a Netlify-hosted site, the cleanest setup is:

- `POST /api/subscribe` to save subscriptions
- `POST /api/send-notification` to send a message
- A small JSON store or database for saved subscriptions

## Data you will need

### Subscription record

Each browser subscription should store:

- `endpoint`
- `p256dh`
- `auth`
- `createdAt`
- `deviceType`

### Notification payload

Each notification can include:

- `title`
- `body`
- `url`
- `tag`
- `image` optional

## Next steps for setup

1. Generate VAPID keys
2. Save the public key in the frontend
3. Build a subscription endpoint
4. Save subscriptions in a database or JSON store
5. Build a send endpoint
6. Test with one browser first

## Important note

Push notifications cannot be fully completed from the browser alone.
The frontend can ask for permission and show notifications, but a backend is still required to deliver them later.

## Files involved

- `install.html`
- `script.js`
- `service-worker.js`
- `push-notifications/README.md`

