# PRD — Nadiplayer push reset + football-data + LiveTV scale controls

## Original Problem Statement
User reported:
- Installed on 2 devices but notifications still failing
- Admin panel still shows old 18 devices from older app versions
- Wants reset-to-zero without touching users/xtream
- Wants football-data.org API option in admin panel (not JSON-only)
- Wants LiveTV playback size controls (fit/full/zoom)

## Architecture Decisions
- Keep existing user/xtream data untouched.
- Treat `fcm_tokens` as push-source-of-truth; expose legacy `devices` table separately.
- Add admin-side cleanup controls and SQL script for safe resets.
- Add football-data.org import as optional source in cPanel World Cup panel.
- Add LiveTV scale mode UI in React player path.

## What’s Implemented
1) Push/Device reliability + cleanup
- Added push cleanup controls in cPanel Broadcast page:
  - keep version filter (`1.0.1`)
  - hard reset `fcm_tokens` to zero
  - optional legacy `devices` clear to remove old “18 devices” count
- Added version-targeted sending in cPanel broadcast (all/single user)
- Updated dashboard/broadcast labeling to distinguish push tokens vs legacy devices
- Added settings controls for `push_enabled` and `push_target_app_version`
- Updated default settings in PHP API:
  - `app_version = 1.0.1`
  - `push_enabled = true`
- Device token registration now mirrors device_id into legacy `devices` table (non-blocking)

2) SQL cleanup script (no users/xtream touched)
- Added: `release-bundle/nadiplayer/sql/reset_push_keep_users_xtream.sql`
- Clears: `fcm_tokens`, `fcm_broadcasts`, `stats_heartbeats`, `installs`
- Optional line to clear `devices`
- Does NOT modify users/xtream credentials/settings

3) World Cup source option (football-data.org)
- Added cPanel World Cup import form for football-data.org API key + competition code
- Added handler to fetch from `https://api.football-data.org/v4/competitions/{code}/matches`
- Maps official matches into local World Cup fixtures and keeps auto-notify flow

4) LiveTV playback size controls
- Added UI controls in LiveTV page:
  - Fit (`contain`)
  - Full/Zoom (`cover`)
  - Stretch (`fill`)
- Persisted selection in localStorage
- Wired mode into InlinePreviewPlayer and VideoPlayer for live streams

## Known External Blocker
- Push delivery from this local preview still shows Firebase credential error in local backend logs (`invalid_grant: Invalid JWT Signature`) because preview environment key/runtime is not your cPanel production runtime.
- Your cPanel deployment with new matching Firebase files should be validated directly there.

## Prioritized Backlog
### P0
- Deploy updated `release-bundle/nadiplayer` to cPanel
- Run push cleanup once (hard reset + optional legacy clear)
- Reopen app on 2 devices to re-register fresh tokens
- Send test push filtered to `1.0.1`

### P1
- Add token diagnostics table in cPanel (last_seen, app_version, invalid reasons)
- Add scheduled football-data auto-sync cron task

### P2
- Per-channel/competition subscription alerts
- Rich notification analytics (open/click) in admin panel

## Next Tasks
1. In cPanel admin: Broadcast -> Reset/Clean -> hard reset tokens (+ optional legacy devices).
2. Open app on both devices, login once, keep app foreground for 10–15 seconds.
3. Send a push with version filter `1.0.1` and verify delivery.
