I want to use the new FCM HTTP v1 API, which is documented here FCM HTTP v1 API Documentation, to send a notification to multiple devices at once, but without using topics, or groups (let's say I want to send a notification to 10 random winners of some lottery). I know that in the previous version (Legacy FCM HTTP Protocol), this was possible by using the registration_ids parameter, but I don't see anything similar in the current API. Am I missing something? Is there a way to do this without using the legacy API?
For sending FCM notification payload you can use Firebase Cloud Messaging Tool in firebase console. And click on Send your first message. Then enter the Title and body field. If you wish to send it to a particular device then click on Send test message and enter the FCM registration token.
There is currently no other way to send to multiple tokens besides using topics for FCM v1.
In your mentioned use case, if I'm using v1, I would probably go at something like, after selecting the winning tokens, you subscribe them to a topic like winningTokens<date_here>
then send the message.
For other use cases, the best way to send to multiple devices via v1 API depends on your application. For example, the accepted answer would not be a good solution for a private chat application where another user can guess the topic name and evesdrop on the conversation by subscribing to the topic. In that scenario iterating over the device list and making multiple send calls to a single device would be better.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With