# SMS alerts through your own phone (v45)

No SMS provider and no API account. Your Android phone (with a SIM) sends the texts.

## Install
1. Extract the zip over `public_html`, then run **migrations_v45_sms.sql** (Admin > More > Migrations).
2. Admin > More > **SMS**: tick "SMS alerts are ON", choose which alerts to send, check the limits, Save.
3. On the phone: install an Android gateway app that uses the **SMSSync** method. Give it SMS permission and exclude it from battery saving.
   - Sync URL: shown on the SMS admin page (`https://yourdomain.com/sms_gateway.php`)
   - Secret key: shown on the same page (if the app says the key is wrong, put it at the end of the URL instead: `.../sms_gateway.php/YOURKEY`)
   - Turn on task checking (every 1 minute), delivery reports, and forwarding of incoming SMS.
4. Use "Send test SMS" on the admin page. It should arrive within about a minute.

## How members get texts
- Members switch it on themselves: Settings > Notifications > SMS alerts (needs a phone number on their profile). They get one confirmation text.
- A text is only queued if: SMS is ON, that alert type is allowed, the member opted in, they have been away at least 30 minutes, they have had fewer than 2 texts today, and it is not the quiet period (default 21:00-07:00 Nairobi time; texts wait until morning).
- Alerts: new match, new chat message, friend request, missed call, weekly list, verification result. Texts never include names or message content.
- Members reply **STOP** (or ACHA / SITISHA) to switch SMS off. This works when the phone app forwards incoming SMS to the site.

## Keep your SIM safe
The phone-wide daily cap (default 150) protects your SIM from being blocked for spam. Raise it slowly. Keep the phone charged, on, with signal and airtime/bundle. If the phone is off, texts wait in the queue (up to 2 days) and the admin page shows "not seen for ...".
Do not use this for login codes: it is not instant or guaranteed.

## Privacy
Phone numbers are shown masked in the admin queue. Members can delete their account (their queued texts are removed). Only send texts people agreed to receive.

## No gateway app? Use the Phone sender page (admin/sms_sender.php)
A web page cannot send SMS silently, so this page makes it one tap per text:
1. Open `https://yourdomain.com/admin/sms_sender.php` on the sending phone (logged in as admin), or wrap that URL into your APK.
2. Tap "Send next text". Messages opens with the number and text already filled in.
3. Press Send in Messages, return, tap "Yes, sent".
The page shows how many texts are waiting and buzzes when new ones arrive while it is open. Texts are sent one at a time on purpose, so members never see each other's numbers.
