The device group messaging feature has been deprecated and will stop working
after September 29, 2027. The instructions help you migrate off the feature.

## Manage your own group-tokens mapping

Because FCM will no longer store your device groups, you must build and maintain
your own mapping between your groups (such as a user ID) and their associated
FCM registration tokens on your app server. We recommend using a persistent
storage solution, like Cloud Firestore, Realtime Database, or a relational
database.

When a client app starts up or its token refreshes, it should capture the token
and send it to your backend to be stored. Your backend then associates that
token with the appropriate user or group.

## Retrieve your existing group-tokens mapping

FCM device group management APIs offer a [GET method](https://firebase.google.com/docs/cloud-messaging/device-group#retrieving_tokens)
for retrieving the list of registration tokens that belong to a given
`notification_key`.

WARNING: The API for retrieving group-tokens mapping will be turned down on
September 29, 2027 and the data won't be retained afterwards. Retrieve you group
data before September 29, 2027 if you need.

## Send messages to each token of a group

To send a message to a group using your newly managed group-tokens mappings,
retrieve the list of tokens from your database.

If you are using the Firebase Admin SDK, you can use the multicast messaging API
(`sendEachForMulticast`) to send a single message payload to multiple tokens at
once.

If you are calling the FCM HTTP v1 API directly, you must make a separate HTTP
request for each token in your group, iterating over the list of registration
tokens and sending a request with the `token` field explicitly set in the
message payload.

## Use topic messaging for large fanout

[Topic messaging](https://firebase.google.com/docs/cloud-messaging/topic-messaging) is not a direct
replacement for group messaging. Topics are optimized for throughput rather than
latency, and recommended for large fanout. You can learn more about how to
[manage topic subscriptions](https://firebase.google.com/docs/cloud-messaging/manage-topic-subscriptions)
and [send messages to topics](https://firebase.google.com/docs/cloud-messaging/send-topic-messages) if it
works for you.