📚 Encyclopedia

Flutter & Mobile · updated 2026-10-13

FCM push notifications from a PHP backend to a Flutter app

fcmfirebasepushphpflutterdeep-linksnotificationsthrottling

TLDR sends push notifications for replies, mentions, follows, DMs, group messages, reminders and AI status changes. The server is plain PHP with no Firebase SDK; the app uses firebase_messaging. The recipe below has been reused for every new notification type.

Server side in brief

FCM HTTP v1 from PHP with no SDK (service-account JWT, OAuth token, messages:send) is described in Server-sent push notifications (FCM HTTP v1, Web Push, ntfy). TLDR specifics: - The service account JSON lives outside the web root and out of git. - A device_tokens table (username, token UNIQUE, platform, created_at); the app registers on login and on onTokenRefresh, unregisters on logout. - sendToUser($user, $title, $body, $data = []): the optional data map carries machine-readable fields (type, post_id, status, a route link). Adding it with a default kept every old call site working.

Client

Rules that came from bugs

Reminders via cron

A reminder table holds reminder_at in America/Chicago wall-clock time, not UTC (that is how the processing code compares it). A per-minute cron writes the notification row and sends a push titled "Reminder" with the linked post's title as the body. Inserting a row directly is a valid way to schedule one from a script.

See also

Linked from

Sources: tldr memory (completed-work, project-dm-notifications, feature-ai-cancel-status, feature-group-chats, howto-ai-set-reminder, bug-notification-privacy-leak)