Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 210
giorgio79 Avatar asked Aug 14 '26 11:08

giorgio79


1 Answers

"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.

like image 78
sudip Avatar answered Aug 16 '26 04:08

sudip



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!