Skip to main content
RapidDev - Software Development Agency
flutterflow-tutorials

How to Send Push Notifications to Specific Users in FlutterFlow

FlutterFlow's built-in Push Notifications action handles individual users by FCM token and topic-based broadcasts. For segment-based targeting (e.g., all users who completed onboarding), query Firestore for matching users and send via a Firebase Cloud Function using sendMulticast — not one-at-a-time token iteration. Always store FCM tokens in Firestore, refresh them on app start, and use topics for interest-group broadcasts.

What you'll learn

  • How to store, refresh, and target individual users by FCM token stored in Firestore
  • How to use FCM topics for interest-group push notifications without managing token lists
  • How to send batch notifications to user segments via Firebase Cloud Functions
  • How to build an admin compose-and-send UI in FlutterFlow
Book a free consultation
4.9Clutch rating
600+Happy partners
17+Countries served
190+Team members
Beginner10 min read25-35 minFlutterFlow Free+March 2026RapidDev Engineering Team
TL;DR

FlutterFlow's built-in Push Notifications action handles individual users by FCM token and topic-based broadcasts. For segment-based targeting (e.g., all users who completed onboarding), query Firestore for matching users and send via a Firebase Cloud Function using sendMulticast — not one-at-a-time token iteration. Always store FCM tokens in Firestore, refresh them on app start, and use topics for interest-group broadcasts.

Four Ways to Target Push Notifications in FlutterFlow

FlutterFlow's built-in Push Notification action covers the simplest case — sending to a known user by their Firestore document reference. Beyond that, you need to understand FCM's three targeting strategies: direct token delivery for individual users, topic subscriptions for opt-in interest groups, and Firestore-query-based segments for rule-based targeting (all free-tier users, all users inactive for 30 days). Each strategy has different tradeoffs in speed, scalability, and maintenance complexity.

Prerequisites

  • A FlutterFlow project with Firebase connected and Push Notifications enabled in FlutterFlow Settings
  • An Android physical device or iOS device (simulators do not support push notifications)
  • Your Firebase project on the Blaze plan if using Cloud Functions for batch sends
  • FCM tokens being stored in your Firestore 'users' collection (covered in Step 1)

Step-by-step guide

1

Store and refresh FCM tokens on every app launch

Open FlutterFlow's Action Flow editor for your Main page or initial route's On Page Load event. Add an action: Push Notifications → Request Permission (iOS only — Android grants automatically). Add a second Custom Action named 'saveFcmToken'. This action calls FirebaseMessaging.instance.getToken() to retrieve the current FCM token, then writes it to the authenticated user's Firestore document under the field 'fcmToken' (String) and 'fcmTokenUpdatedAt' (DateTime). FCM tokens can be rotated by the OS — if you only save the token at registration and never refresh it, you'll accumulate stale tokens and miss deliveries.

save_fcm_token.dart
1// Custom Action: saveFcmToken
2import 'package:firebase_messaging/firebase_messaging.dart';
3import 'package:cloud_firestore/cloud_firestore.dart';
4import 'package:firebase_auth/firebase_auth.dart';
5
6Future<void> saveFcmToken() async {
7 final user = FirebaseAuth.instance.currentUser;
8 if (user == null) return;
9 final token = await FirebaseMessaging.instance.getToken();
10 if (token == null) return;
11 await FirebaseFirestore.instance
12 .collection('users')
13 .doc(user.uid)
14 .update({
15 'fcmToken': token,
16 'fcmTokenUpdatedAt': FieldValue.serverTimestamp(),
17 });
18}

Expected result: After login, each user's Firestore document shows an updated 'fcmToken' field with a recent 'fcmTokenUpdatedAt' timestamp.

2

Send to an individual user using FlutterFlow's built-in action

In FlutterFlow, navigate to the Action Flow where you want to trigger a push (e.g., an admin button or an in-app event). Add action: Notifications → Push Notification. In the recipient field, select a Firestore Document Reference — this should be the target user's document from your 'users' collection. Fill in Title and Body using dynamic values from your data. This built-in action reads the fcmToken from the referenced user document and sends via Firebase Cloud Messaging automatically. For notifications triggered by one user's action affecting another user (like a new message), pass the recipient user's document reference through your data flow.

Expected result: Tapping the trigger action delivers a push notification to the target user's device within 2-5 seconds.

3

Set up topic-based push for interest groups

Topics let you send one notification to all users subscribed to a named topic (e.g., 'sports-updates', 'sale-alerts') without managing individual tokens. Create a Custom Action named 'subscribeToTopic' that calls FirebaseMessaging.instance.subscribeToTopic(topicName). Call this action when users opt into interest categories (e.g., in your notification preferences screen). Create a corresponding 'unsubscribeFromTopic' action. To send to a topic, create a Cloud Function (see Step 4) that calls the FCM API with the topic as the target. Topics scale to millions of subscribers — FCM handles the fan-out for you.

topic_subscription.dart
1// Custom Actions: subscribeToTopic / unsubscribeFromTopic
2import 'package:firebase_messaging/firebase_messaging.dart';
3
4Future<void> subscribeToTopic(String topicName) async {
5 await FirebaseMessaging.instance.subscribeToTopic(topicName);
6}
7
8Future<void> unsubscribeFromTopic(String topicName) async {
9 await FirebaseMessaging.instance.unsubscribeFromTopic(topicName);
10}

Expected result: After calling subscribeToTopic('sale-alerts'), the user's device receives any notification sent to the 'sale-alerts' FCM topic.

4

Send batch notifications to Firestore-queried segments via Cloud Functions

For segment targeting (all inactive users, all premium subscribers, users in a specific city), create a Cloud Function named 'sendSegmentNotification'. The function accepts: segment query parameters, notification title, and body. It queries Firestore for matching users, extracts their fcmToken fields, filters out null/empty tokens, then calls messaging.sendEachForMulticast() — NOT a loop of individual send() calls. sendEachForMulticast accepts up to 500 tokens per call, so paginate your Firestore query in batches of 500. This approach is 50-100x faster than sending one-at-a-time for large user bases.

sendSegmentNotification.js
1// Cloud Function: sendSegmentNotification
2const admin = require('firebase-admin');
3const functions = require('firebase-functions');
4
5admin.initializeApp();
6
7exports.sendSegmentNotification = functions.https.onCall(
8 async (data, context) => {
9 if (!context.auth?.token.admin) {
10 throw new functions.https.HttpsError('permission-denied', 'Admin only');
11 }
12 const { segment, title, body } = data;
13 const db = admin.firestore();
14 let query = db.collection('users').where('fcmToken', '!=', '');
15 if (segment === 'premium') {
16 query = query.where('plan', '==', 'premium');
17 } else if (segment === 'inactive_30d') {
18 const cutoff = new Date(Date.now() - 30 * 24 * 60 * 60 * 1000);
19 query = query.where('lastActiveAt', '<', cutoff);
20 }
21 const snap = await query.get();
22 const tokens = snap.docs
23 .map((d) => d.data().fcmToken)
24 .filter(Boolean);
25 if (tokens.length === 0) return { sent: 0 };
26
27 // Batch in groups of 500
28 const BATCH = 500;
29 let totalSent = 0;
30 for (let i = 0; i < tokens.length; i += BATCH) {
31 const batch = tokens.slice(i, i + BATCH);
32 const res = await admin.messaging().sendEachForMulticast({
33 tokens: batch,
34 notification: { title, body },
35 });
36 totalSent += res.successCount;
37 }
38 return { sent: totalSent };
39 }
40);

Expected result: The Cloud Function sends to all matching users and returns a count of successful deliveries; the call completes in seconds even for thousands of users.

5

Build the admin compose and send UI in FlutterFlow

Create a new admin-only page in FlutterFlow named 'Send Notification'. Add a Conditional widget at the top to redirect non-admin users. Inside, add: a DropdownButton for segment selection (Individual, Topic, Premium Users, Inactive 30 Days), a TextField for recipient search (for Individual mode, queries users by name/email), a TextField for notification Title, a TextField for notification Body, a character count indicator, and a large Send button. For Individual mode, use FlutterFlow's built-in Push Notification action. For Topic and Segment modes, call the Cloud Function via an API call action, passing the selected segment, title, and body as parameters. Show a success Snackbar with the delivery count on completion.

Expected result: The admin page allows selecting a target, composing a message, and sending — with real-time feedback on delivery count.

Complete working example

push_notification_helpers.dart
1// Push notification helper Custom Actions
2// Add to FlutterFlow Custom Code panel
3
4import 'package:firebase_messaging/firebase_messaging.dart';
5import 'package:cloud_firestore/cloud_firestore.dart';
6import 'package:firebase_auth/firebase_auth.dart';
7
8// ─── Save FCM token on launch ─────────────────────────────────────────────────
9Future<void> saveFcmToken() async {
10 final user = FirebaseAuth.instance.currentUser;
11 if (user == null) return;
12 final token = await FirebaseMessaging.instance.getToken();
13 if (token == null) return;
14 await FirebaseFirestore.instance
15 .collection('users')
16 .doc(user.uid)
17 .update({
18 'fcmToken': token,
19 'fcmTokenUpdatedAt': FieldValue.serverTimestamp(),
20 });
21 // Also listen for token rotation
22 FirebaseMessaging.instance.onTokenRefresh.listen((newToken) async {
23 if (FirebaseAuth.instance.currentUser != null) {
24 await FirebaseFirestore.instance
25 .collection('users')
26 .doc(FirebaseAuth.instance.currentUser!.uid)
27 .update({
28 'fcmToken': newToken,
29 'fcmTokenUpdatedAt': FieldValue.serverTimestamp(),
30 });
31 }
32 });
33}
34
35// ─── Subscribe to FCM topic ───────────────────────────────────────────────────
36Future<void> subscribeToTopic(String topicName) async {
37 await FirebaseMessaging.instance.subscribeToTopic(topicName);
38 // Track subscriptions in Firestore for admin analytics
39 final user = FirebaseAuth.instance.currentUser;
40 if (user != null) {
41 await FirebaseFirestore.instance
42 .collection('users')
43 .doc(user.uid)
44 .update({
45 'subscribedTopics': FieldValue.arrayUnion([topicName]),
46 });
47 }
48}
49
50// ─── Unsubscribe from FCM topic ───────────────────────────────────────────────
51Future<void> unsubscribeFromTopic(String topicName) async {
52 await FirebaseMessaging.instance.unsubscribeFromTopic(topicName);
53 final user = FirebaseAuth.instance.currentUser;
54 if (user != null) {
55 await FirebaseFirestore.instance
56 .collection('users')
57 .doc(user.uid)
58 .update({
59 'subscribedTopics': FieldValue.arrayRemove([topicName]),
60 });
61 }
62}
63
64// ─── Request notification permission (iOS) ───────────────────────────────────
65Future<bool> requestNotificationPermission() async {
66 final settings =
67 await FirebaseMessaging.instance.requestPermission(
68 alert: true,
69 badge: true,
70 sound: true,
71 );
72 return settings.authorizationStatus ==
73 AuthorizationStatus.authorized;
74}

Common mistakes when sending Push Notifications to Specific Users in FlutterFlow

Why it's a problem: Sending batch notifications by iterating over tokens one at a time with individual send() calls

How to avoid: Use admin.messaging().sendEachForMulticast() with batches of up to 500 tokens. FCM processes these as a single API call with one HTTP round trip per batch. 10,000 tokens = 20 batched calls, completing in under 10 seconds.

Why it's a problem: Never cleaning up stale or invalid FCM tokens from Firestore

How to avoid: After each sendEachForMulticast call, check the responses array for NOT_FOUND or INVALID_ARGUMENT error codes and delete those tokens from Firestore immediately.

Why it's a problem: Storing the FCM token only once at first app launch and never refreshing it

How to avoid: Call saveFcmToken() in On Page Load on your main page (runs every app open) AND listen to FirebaseMessaging.instance.onTokenRefresh to catch OS-initiated rotations.

Best practices

  • Always request notification permission before trying to get an FCM token — iOS will return nil if permission was not granted.
  • Store subscribed topics in Firestore alongside the FCM token so you have a server-side record of each user's notification preferences for analytics and re-subscription after reinstall.
  • Personalize notification content — include the user's name and a relevant data point (e.g., 'Hey Sarah, your order shipped') to achieve 2-3x higher open rates versus generic messages.
  • Implement notification preference settings in your app so users can opt out of specific categories without disabling all notifications.
  • Log every notification send event to Firestore with timestamp, segment, title, and delivery count — build a send history visible in your admin UI.
  • Use FCM's data-only messages (no notification field) for background data sync that should not display as a visible notification.
  • Test push notifications on physical devices before shipping — simulators and emulators return token values but never actually deliver notifications.

Still stuck?

Copy one of these prompts to get a personalized, step-by-step explanation.

ChatGPT Prompt

I'm building a FlutterFlow app with Firebase. I need to send push notifications to specific user segments. Segment 1: all users who haven't opened the app in 30 days. Segment 2: all users with plan='premium' in Firestore. Write me a Firebase Cloud Function using the Admin SDK that accepts a segment name, notification title, and body, then queries Firestore for matching users, extracts their FCM tokens, and sends using sendEachForMulticast in batches of 500. Include error handling for stale tokens.

FlutterFlow Prompt

In my FlutterFlow app, I have a Custom Action that calls Firebase Messaging to get the FCM token and save it to Firestore. The action runs on every app launch. I also need the token to update whenever FCM rotates it. Show me the complete Dart code for this Custom Action including the onTokenRefresh listener, and explain how to call it from FlutterFlow's On Page Load action flow.

Frequently asked questions

Can FlutterFlow's built-in Push Notification action send to multiple users at once?

No. FlutterFlow's built-in action sends to a single Firestore document reference at a time. For bulk sends to multiple users, you need a Firebase Cloud Function that uses the Admin SDK's sendEachForMulticast method, called via FlutterFlow's API call action or a Custom Action.

What is the difference between a topic and a segment for push notifications?

A topic is a subscription model — users opt in to a named channel on their device, and FCM maintains the subscription list for you. A segment is a server-side query — you query Firestore for users matching certain criteria and then send to their tokens. Topics are simpler and scale better; segments give you more dynamic targeting based on current database state.

How do I send push notifications to users who unsubscribed from all notifications?

You cannot and should not. If a user has denied notification permission or turned off notifications in device settings, their device simply will not display the notification even if FCM delivers it. Always respect user notification preferences and never attempt to bypass operating system-level notification controls.

How do I deep link from a push notification to a specific page in my FlutterFlow app?

Include a 'data' payload in your FCM message with a 'route' field (e.g., '/product/abc123'). In your app's notification handler (FirebaseMessaging.onMessageOpenedApp stream), read the route from the message data and use FlutterFlow's navigation actions to go to that page. Set up Go Router or FlutterFlow's routing to handle the deep link path.

Are push notifications free in FlutterFlow and Firebase?

FCM (Firebase Cloud Messaging) itself is free with no limits on messages sent. The only cost is from the Firebase Cloud Functions you run to do segment-based sends — those are charged per invocation on the Blaze plan after the free tier (2 million/month). For most apps, push notification infrastructure costs less than $1/month.

How do I send a notification when a Firestore document is created or updated?

Create a Firebase Cloud Function with a Firestore trigger (onDocumentCreate or onDocumentUpdate). Inside the function, read the target user's FCM token from their user document and call admin.messaging().send() with the notification payload. This is the standard pattern for event-triggered notifications like 'new message' or 'order shipped'.

RapidDev

Talk to an Expert

Our team has built 600+ apps. Get personalized help with your project.

Book a free consultation

Need help with your project?

Our experts have built 600+ apps and can accelerate your development. Book a free consultation — no strings attached.

Book a free consultation

We put the rapid in RapidDev

Need a dedicated strategic tech and growth partner? Discover what RapidDev can do for your business! Book a call with our team to schedule a free, no-obligation consultation. We'll discuss your project and provide a custom quote at no cost.