Push Notifications in Flutter with Supabase Edge Functions + FCM
Send push notifications from Supabase to your Flutter app: store FCM tokens in Postgres, trigger a Deno Edge Function via database webhooks, authenticate with FCM HTTP v1 — plus the token-refresh, multi-device, and webhook-security gaps most tutorials skip.
TL;DR: Supabase doesn't send push notifications itself — Firebase Cloud Messaging does. The production pattern: (1) your Flutter app gets an FCM token and saves it to a profiles table in Supabase, (2) a database webhook fires on interesting events (new order, new message), (3) the webhook calls a Supabase Edge Function, (4) the function authenticates to FCM's HTTP v1 API with a service-account OAuth2 token and sends the push. This guide walks through all four steps, then covers what most tutorials skip: token refresh, multi-device users, iOS quirks, and securing your webhook endpoint. What you'll learn The 4-part architecture: Flutter app → Supabase → Edge Function → FCM → device Storing FCM tokens in Postgres (and why one column isn't enough) Writing the Edge Function that talks to FCM HTTP v1 with a service account Wiring database webhooks to trigger pushes on row inserts The --no-verify-jwt gotcha that silently eats your first test What tutorials skip: token rotation, multi-device, foreground handling, iOS setup, webhook security The architecture in 30 seconds Push notifications need four pieces, and each lives in a different place: Flutter app — requests permission, obtains an FCM token from Firebase, saves it to Supabase. Supabase Postgres — stores one row per (user, device) with the current FCM token. Database webhook — fires when something worth notifying about happens (a new order, a new chat message). Edge Function — receives the webhook, looks up the recipient's token(s), and calls FCM. FCM is the actual delivery service in every case — Supabase is the trigger and the token store. Once you see it this way, each step becomes obvious. For the Flutter-side deep dive (foreground/background handling, tap actions, iOS config), see the…