You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何通过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:

  1. Create each individual FCM request as you normally would (each with its own condition and notification payload).
  2. Wrap all requests into a single batch request following the multipart/mixed content 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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.05 03:55:14