javascriptfirebase-cloud-messaging

Send Notification To All Firebase Cloud Messaging Tokens (Web)


Angular web app (not a native app)
I have my logic working to generate and save FCM tokens.
And I can send a send a message to one token using curl in the terminal.
I have been reviewing MANY tutorials and all I have seen send messages to one token at a time.

Is it possible to send a message to all the tokens you have saved in your Firebase Realtime Database?
Do I need to use (or build) some other tool to do this?


Solution

  • Thre is no built-in mechanism in Firebase Cloud Messaging to send a message to "all tokens".

    Instead you can call the FCM legacy API to send a message to a collection of up to 1000 tokens at a time. The key is to use the registration_ids parameter (instead of the to parameter for a single token), as AL explains here: FCM (Firebase Cloud Messaging) Send to multiple devices and here: FCM: Message to multiple registration ids limit?, and as shown in the documentation for the legacy API.