Search code examples
firebase-cloud-messaging

FCM batch messages URL


I want send multiple notifications with one HTTP request to Firebase using REST API

Documentation says - "You should combine requests and send" https://firebase.google.com/docs/cloud-messaging/send-message#send-messages-to-multiple-devices

curl command for send is curl *** -H 'Content-Type: multipart/mixed; boundary="subrequest_boundary"' https://fcm.googleapis.com/batch

I found that https://fcm.googleapis.com/batch url is no longer supported https://developers.googleblog.com/2018/03/discontinuing-support-for-json-rpc-and.html

What right url for send multiple notifications to FCM?


Solution

  • There is a new API for sending messages through Firebase Cloud Messaging, called the versioned API. It lives on /v1/projects/<your-project-id>/messages:send and is fully documented in the Firebase documentation on sending requests.

    In this new, versioned API sending multiple messages through the regular end point by sending a multi-part request to it. This process is fully documented in the section on sending a batch of messages and is also wrapped by most of the Admin SDKs that are available.


    Update: from the documentation on sending batch messages:

    Important: The batch send methods described in this section were deprecated on June 21, 2023, and will be removed in June 2024. For protocol, instead use the standard HTTP v1 API send method, implementing your own batch send by iterating through the list of recipients and sending to each recipient's token. For Admin SDK methods, make sure to update to the next major version. See the Firebase FAQ on FCM features deprecated in June 2023 for more information.