Stay organized with collections
Save and categorize content based on your preferences.
Based on the publish/subscribe model, FCM topic messaging allows you to send a message
to multiple devices that have opted in to a particular topic. You compose topic messages as
needed, and FCM handles routing and delivering the message reliably to the right
devices.
For example, users of a local tide
forecasting app could opt in to a "tidal currents alerts" topic and receive
notifications of optimal saltwater fishing conditions in specified areas. Users of a sports app
could subscribe to automatic updates in live game scores for their favorite
teams.
Some things to keep in mind about topics:
Topic messaging is best suited for content such as weather, or other publicly
available information.
Topic messages are optimized for throughput rather than latency. For fast,
secure delivery to single devices or small groups of devices,
target messages to registration tokens,
not topics.
If you need to send messages to multiple devices per user, consider
device group messaging
for those use cases.
Topic messaging supports unlimited subscriptions for each topic. However, FCM
enforces limits in these areas:
One app instance can be subscribed to no more than 2000 topics.
If you are using batch import
to subscribe app instances, each request is limited to 1000 app instances.
The frequency of new subscriptions is rate-limited per project. If you send
too many subscription requests in a short period of time, FCM servers will
respond with a 429 RESOURCE_EXHAUSTED ("quota exceeded") response. Retry
with exponential backoff.
Subscribe the client app to a topic
Client apps can subscribe to any existing topic, or they can create a new
topic. When a client app subscribes to a new topic name (one that does
not already exist for your Firebase project), a new topic of that name is
created in FCM and any client can subsequently subscribe to it.
To subscribe to a topic, call subscribeToTopic() with the topic name. This method
returns a Future, which resolves when the subscription succeeded:
To unsubscribe, call unsubscribeFromTopic() with the topic name.
subscribeToTopic() and unsubscribeFromTopic() are not supported for web
clients. To learn how to manage subscriptions for web users, see
Send messages to topics on Web/JavaScript.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-27 UTC."],[],[],null,["\u003cbr /\u003e\n\nBased on the publish/subscribe model, FCM topic messaging allows you to send a message\nto multiple devices that have opted in to a particular topic. You compose topic messages as\nneeded, and FCM handles routing and delivering the message reliably to the right\ndevices.\n\nFor example, users of a local tide\nforecasting app could opt in to a \"tidal currents alerts\" topic and receive\nnotifications of optimal saltwater fishing conditions in specified areas. Users of a sports app\ncould subscribe to automatic updates in live game scores for their favorite\nteams.\n\nSome things to keep in mind about topics:\n\n- Topic messaging is best suited for content such as weather, or other publicly\n available information.\n\n- Topic messages are **optimized for throughput rather than latency** . For fast,\n secure delivery to single devices or small groups of devices,\n [target messages to registration tokens](/docs/cloud-messaging/send-message#send_messages_to_specific_devices),\n not topics.\n\n- If you need to send messages to multiple devices *per user* , consider\n [device group messaging](/docs/cloud-messaging/send-message#send_messages_to_device_groups)\n for those use cases.\n\n- Topic messaging supports unlimited subscriptions for each topic. However, FCM\n enforces limits in these areas:\n\n - One app instance can be subscribed to no more than 2000 topics.\n - If you are using [batch import](https://developers.google.com/instance-id/reference/server#manage_relationship_maps_for_multiple_app_instances) to subscribe app instances, each request is limited to 1000 app instances.\n - The frequency of new subscriptions is rate-limited per project. If you send too many subscription requests in a short period of time, FCM servers will respond with a `429 RESOURCE_EXHAUSTED` (\"quota exceeded\") response. Retry with exponential backoff.\n\nSubscribe the client app to a topic\n\nClient apps can subscribe to any existing topic, or they can create a new\ntopic. When a client app subscribes to a new topic name (one that does\nnot already exist for your Firebase project), a new topic of that name is\ncreated in FCM and any client can subsequently subscribe to it.\n\nTo subscribe to a topic, call `subscribeToTopic()` with the topic name. This method\nreturns a `Future`, which resolves when the subscription succeeded: \n\n await FirebaseMessaging.instance.subscribeToTopic(\"topic\");\n\nTo unsubscribe, call `unsubscribeFromTopic()` with the topic name.\n\n`subscribeToTopic()` and `unsubscribeFromTopic()` are not supported for web\nclients. To learn how to manage subscriptions for web users, see\n[Send messages to topics on Web/JavaScript](https://firebase.google.com/docs/cloud-messaging/js/topic-messaging).\n\nNext steps\n\n- Learn how to [send topic messages](/docs/cloud-messaging/send-message#send-messages-to-topics).\n- Learn how to [Manage topic subscriptions on the server](/docs/cloud-messaging/manage-topics)."]]