如何通过Google FCM API单次POST请求发送多条推送通知?
Can I send multiple distinct notifications via a single FCM POST request?
No, Firebase Cloud Messaging (FCM) does not support sending multiple unique notification payloads in a single standard POST request. Each FCM request is designed to deliver one notification (or data message) to a target set of devices (specified via condition, topic, or registration tokens).
Alternative: Use FCM Batch Requests
To cut down on network overhead while sending multiple distinct notifications, you can bundle multiple FCM send requests into one HTTP call using Google Cloud's batch request mechanism. This uses a single TCP connection instead of multiple, reducing latency and overhead.
How to implement batch requests:
- Create each individual FCM request as you normally would (each with its own
conditionandnotificationpayload). - Wrap all requests into a single batch request following the
multipart/mixedcontent type format required by Google's batch API.
Example batch request structure:
POST https://fcm.googleapis.com/batch HTTP/1.1 Host: fcm.googleapis.com Authorization: key=YOUR_SERVER_KEY Content-Type: multipart/mixed; boundary=batch_boundary --batch_boundary Content-Type: application/http Content-Transfer-Encoding: binary POST /fcm/send HTTP/1.1 Content-Type: application/json { "condition":"my condition", "notification":{ "title" : "the title 1", "body":"the body 1" } } --batch_boundary Content-Type: application/http Content-Transfer-Encoding: binary POST /fcm/send HTTP/1.1 Content-Type: application/json { "condition":"my condition", "notification":{ "title" : "the title 2", "body":"the body 2" } } --batch_boundary--
Key details about batch requests:
- A single batch can include up to 500 individual FCM requests.
- The response will be a multipart message containing results for each request, so you can handle successes or failures per notification.
- This approach reduces network overhead but each individual notification still counts as a separate FCM message against your quota.
Additional Notes
- If your notifications target the same devices but need to display as separate messages, each requires its own FCM payload—there’s no way to combine them into one request.
- On the client side, each FCM message will trigger a separate notification (assuming your app is configured to display them).
内容的提问来源于stack exchange,提问作者Mohsen Mirshahreza
相关产品推荐
相关产品推荐

