Reputation: 477
From Firebase docs and StackOverflow questions, I understood that we can send Push Notifications to multiple devices through Topic Messaging and Device Group Messaging. But I would like to know if is there a way to trigger Push Notifications to multiple device group in a single FCM send request?
Basically, I don't want to invoke multiple requests for the same push notification message. And the reason why I have multiple device group is because there is of an upper cap on number members (i.e) to a notification_key.
And the reason for which I don't want to publish the message to topics is basically due to my requirement constraint. My requirement is " I have some alert message generated in back-end and the same has to be sent only to few users (A user can log into multiple devices) and the issue that I could foresee with the topic is I could not afford for a dynamic property in topics.
If there is a way to implement with topics please give your suggestions.
Upvotes: 1
Views: 7793
Reputation: 1
Looks like those who need Multicast Messaging should stay with legacy API until an update of the v1 is released. Source: https://firebase.google.com/docs/cloud-messaging/migrate-v1: Any apps that use device group messaging or multicast messaging, however, may prefer to wait for future versions of the API. HTTP v1 does not ...
Upvotes: 0
Reputation: 931
Currently from what I could understand reading the FCM doc they don't allow sending notification to Multiple device groups in single request like they do with registration_ids
so I would suggest to use topic to group users like we do with devices
Something like this
When user login subscribe the user to a topic with it's own userId
or some other unique identifier of the user
So same user can be reached at same topic which is named after it's userId
There wouldn't be any registration_ids
limit (1-1000) so this would help in case you have more than 1000 registration_ids
to send in request
Upvotes: 1
Reputation: 176
You need to handle it on server side. You can use firebase group device notification.
For the first token, create a notification key using create operation. For rest of the token, use add operation to add to the same notification key.
Note - it is limit to 20 devices. For ref check below link. https://developers.google.com/cloud-messaging/notifications
Upvotes: 5
Reputation: 421
After reading so many comments I am not sure if I got your question correctly but as per my understanding what you require is Multicast Messaging.
Instead of specifying the to key you may simply specify registration_ids key in your fcm request.
registration_ids (String array) :
This parameter specifies a list of devices (registration tokens, or IDs) receiving a multicast message. It must contain at least 1 and at most 1000 registration tokens. Use this parameter only for multicast messaging, not for single recipients. Multicast messages (sending to more than 1 registration tokens) are allowed using HTTP JSON format only.
For more info refer this.
Upvotes: 6