'FCM push notification to multiple devices (different users) sendMulticast vs sendToDevice in a nodeJS Google Cloud Function?

It seems that the fcm API allows sending to multiple tokens via sendToDevice and sendMulticast. sendToDevice is a legacy call? Should we use sendMulticast instead?

https://firebase.google.com/docs/reference/admin/node/admin.messaging.Messaging#sendtodevice https://firebase.google.com/docs/reference/admin/node/admin.messaging.Messaging#sendmulticast



Solution 1:[1]

"sendMulticast" returns Promise for BatchResponse whereas "sendToDevice" returns Promise for MessagingDevicesResponse

From https://firebase.google.com/docs/cloud-messaging/send-message#adminSDK-legacy-send-methods regarding "sendMulticast":

For Firebase Admin SDKs, this operation uses the sendAll() API under the hood, as shown in the examples. The return value is a BatchResponse whose responses list corresponds to the order of the input tokens. This is useful when you want to check which tokens resulted in errors.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 sudip