Mobile & DevOps

FCM Push Notifications Across Web and Mobile

How to run FCM push notifications from one Node.js backend to web browsers, Android and iOS: token storage, Firebase Admin sends, local notifications, deep links and cleanup.

By Devang GandhiUpdated Nov 3, 20267 min read

Notifications are where a business app proves it is useful outside the moment someone opens it. A studio owner hears about a new enquiry, a crew member gets tomorrow's shoot details, a client knows their invoice is ready. FCM push notifications let one backend deliver all of that to web browsers, Android phones and iPhones through a single API.

I use Firebase Cloud Messaging in Client Mitra, a photography studio CRM with web, Android and iOS apps, and in Sublet, an open-source classifieds board. This post covers the architecture, token management, push versus local notifications, and the details that decide whether people keep notifications switched on.

TL;DR

Register each device with FCM, send its token to your backend, and store tokens per user and per device. Send from Node.js with the Firebase Admin SDK, targeting a user's tokens and cleaning up any FCM reports as invalid. Use local notifications for scheduled reminders and push for server events. Include a deep link in every message so tapping it opens the right screen.

key takeaways

  • FCM push notifications let one backend reach web browsers, Android and iOS through a single API.
  • Store device tokens per user and per device, refresh them on every app start, and delete tokens FCM reports as invalid.
  • Use push for server events and local notifications for scheduled reminders the device already knows about.
  • Every notification should deep link to the exact screen it is about, or users learn to ignore them.

How FCM works across platforms

FCM sits between your server and each platform's delivery channel. The Firebase Cloud Messaging docs cover the setup per platform; here is the practical picture.

Platform Client setup Delivery path Gotchas
Android Firebase SDK, notification channel FCM directly Battery optimization on some devices, Android 13+ permission prompt
iOS Firebase SDK, APNs key uploaded to Firebase FCM to APNs Permission prompt timing, background modes
Web Firebase JS SDK, service worker, VAPID key FCM to browser push service Permission must come from a user action; iOS Safari needs the site added to the home screen

Device tokens

Each app install or browser gets an FCM registration token. Tokens change: after reinstalling, clearing data, restoring a phone, or sometimes for no visible reason. Treat them as disposable and refresh on every launch.

Message types

A notification message has a title and body that the OS displays when the app is in the background. A data message carries key-value pairs your code handles. Most of my sends include both: a visible notification plus data like type: "booking" and url: "/bookings/abc123" for routing.

Backend design: tokens, targeting and sending

Store tokens properly

I keep a DeviceToken collection rather than a single token field on the user, because one person often uses a phone, a tablet and a browser.

  1. On login and on every app start, the client sends { token, platform, deviceId, appVersion } to an authenticated endpoint.
  2. Upsert by token, setting userId, businessId, platform and lastSeenAt.
  3. On logout, delete that device's token so the next user of the device does not get your notifications.
  4. When a send fails with an unregistered or invalid-token error, delete the token immediately.
  5. Periodically remove tokens not seen in a long time.

Send with Firebase Admin

From Node.js, the Firebase Admin SDK's messaging().sendEachForMulticast() takes up to 500 tokens and returns a per-token result, which is exactly what you need for cleanup. Build a small notifyUser(userId, { title, body, url, type }) helper that loads the user's tokens, sends, and prunes failures. Product code calls the helper and never touches FCM directly.

Respect roles and preferences

In a multi-user business app, not everyone should get every alert. Decide recipients by role and by user preference: owners get payment alerts, crew get schedule changes, staff who cannot see money never get payment amounts in a notification body. The lock screen is a public surface, so keep sensitive figures out of it.

Push vs. local notifications

Not every reminder needs a server round trip.

Use case Best choice Why
New enquiry or booking Push Server knows first
Payment received Push Event happens on the server
Reminder 1 hour before a shoot Local, with push backup Device knows the schedule, works offline
Daily task digest Push from a cron job Server builds the summary
Chat message Push Other user triggers it

In Flutter, local notifications are scheduled on the device with a plugin, and they fire even with no connection. For critical reminders, I pair them with a server-side cron push so a reinstall or a new device does not silently lose the reminder.

Deep links

Every message carries a url. When the user taps it, the app routes there. In a WebView-based app, the native shell receives the tap and tells the WebView to navigate to that path, so one routing scheme works on web and mobile.

How I built this in practice

Client Mitra is my solo build: a multi-tenant CRM for photography studios and creative businesses, with enquiries, bookings, crew calendars for multi-day weddings, tasks, GST invoices and payments. It runs as a Next.js web app with a Node/Express and MongoDB backend, and ships native Android and iOS apps through one Flutter wrapper using flutter_inappwebview. The details are in the Client Mitra case study.

The Flutter shell handles FCM push plus local notifications natively, and the backend sends through Firebase Admin. node-cron drives scheduled reminders from the server. Because roles matter (owner, manager and staff, with staff unable to see money), recipients and message content follow the same permission rules as the app itself. The shell also runs Crashlytics, which helps diagnose notification-handling crashes on specific devices. For context on how studios use these alerts, see the photography studios industry page.

In Sublet, my open-source classifieds board for sharing spare Claude and ChatGPT capacity, FCM delivers chat notifications alongside Firebase Auth, while 1:1 chat itself runs on Socket.IO with REST polling as a fallback on serverless hosting.

Common mistakes

  • Storing a single token per user, so only the last device ever receives notifications.
  • Never deleting invalid tokens, which slows sends and clutters logs.
  • Asking for notification permission on first launch, before the user sees any value.
  • Putting sensitive amounts or personal details in notification text visible on the lock screen.
  • Sending notifications with no deep link, dropping users on the home screen.
  • Forgetting to upload an APNs key, then wondering why iOS gets nothing.

keep reading

FAQ

Can FCM send push notifications to iOS devices?+

Yes. FCM delivers to iOS through Apple Push Notification service. You upload an APNs authentication key to your Firebase project, and FCM handles the handoff to Apple.

Does FCM work for web push notifications?+

Yes. FCM supports web push in browsers that implement the Push API, using a service worker and a VAPID key. Users must grant notification permission in the browser first.

What is the difference between push and local notifications?+

Push notifications are sent from your server through FCM when something happens, like a new booking. Local notifications are scheduled on the device itself, which suits reminders the app already knows about, and they work without a network connection.

Why are my FCM notifications not arriving?+

Common causes are stale or invalid tokens, missing notification permission, missing APNs configuration for iOS, battery optimization on some Android devices, or sending data-only messages that the app does not handle in the background.

Is FCM free to use?+

Firebase Cloud Messaging itself has no per-message charge at the time of writing. Your costs are the backend that decides when to send and any other Firebase services you use.

Devang Gandhi

AI & full stack developer at Passdn, building CRMs, SaaS, AI agents and Flutter apps for clients in the US, UK, Australia, UAE and India. More about me

Read next

More in Mobile & DevOps