tasq/supabase/functions/process_scheduled_notifications
Marc Rejohn Castillano 758869920c Fix push notifications never delivered — 3 root causes
1. CRITICAL: Double idempotency check silently discarded every notification.
   process_scheduled_notifications called try_mark_notification_pushed first,
   then send_fcm called it again and saw "already pushed" → skipped FCM send.
   Fix: Remove the check from process_scheduled_notifications; send_fcm's
   own check is sufficient (and needed for direct Flutter client calls).

2. SEND_FCM_URL env var crash: If not configured, edge function crashed on
   module load. Fix: Derive from SUPABASE_URL (always auto-set) as fallback.

3. Timing windows too narrow: ±30s windows with 60s cron intervals could
   miss events between runs. Fix: Widen to ±90s. ON CONFLICT DO NOTHING
   prevents duplicates, making wider windows safe.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-20 20:50:45 +08:00
..
index.ts Fix push notifications never delivered — 3 root causes 2026-03-20 20:50:45 +08:00