---
metadata:
  - name: generator
    content: Diplodoc Platform v5.64.0
alternate:
  - https://boost.yandex.com/doc/en/analytics/content/mobile-api/push/post-send-batch.md
  - https://boost.yandex.com/doc/ru/analytics/content/mobile-api/push/post-send-batch.md
  - https://boost.yandex.com/doc/zh/analytics/content/mobile-api/push/post-send-batch.md
  - href: https://boost.yandex.com/doc/zh/analytics/content/mobile-api/push/post-send-batch.md
    type: text/markdown
    title: Markdown version
  - href: https://boost.yandex.com/doc/zh/llms.txt?revision=r21738064
    rel: describedby
---
> **Documentation Index:** Fetch the complete configuration index at https://boost.yandex.com/doc/zh/llms.txt?revision=r21738064

# 发送推送消息

向指定设备发送一个或多个推送消息。

此操作允许您在单个 HTTP 请求中发送具有不同属性（例如文本、媒体附件等）的消息。 每个请求可以包含最多 250,000 台设备，这些设备将收到消息。

{% note info %}

我们建议使用此操作，而不是已弃用的`POST /push/v1/send`.

{% endnote %}

## 请求格式 {#request_format}

```
POST https://push.api.appmetrica.yandex.net/push/v1/send-batch
```

## Request body {#request_body}

```json translate=no
{
  "push_batch_request": {
    "group_id": 1,
    "client_transfer_id": long,
    "tag": "string",
    "batch": [
      {
        "messages": {
          "android": {
            "silent": false,
            "content": {
              "title": "string",
              "text": "string",
              "icon": "string",
              "icon_background": "#AARRGGBB",
              "image": "https://example.com/picture.jpg",
              "banner": "https://example.com/picture.jpg",
              "data": "string",
              "channel_id": "string",
              "priority": -2,
              "collapse_key": 2001,
              "vibration": [0, 500],
              "led_color": "#RRGGBB",
              "led_interval": 50,
              "led_pause_interval": 50,
              "time_to_live": 180,
              "visibility": "public",
              "urgency": "high"
            },
            "open_action": {
              "deeplink": "yandexmaps://?"
            }
          },
          "iOS": {
            "silent": false,
            "content": {
              "title": "string",
              "text": "string",
              "badge": 1,
              "sound": "disable",
              "thread_id": "string",
              "category": "string",
              "mutable_content": 1,
              "expiration": 3600,
              "data": "string",
              "collapse_id": "string",
              "attachments": [
                {
                    "id": "string",
                    "file_url": "string",
                    "file_type": "string"
                },
                ...
              ]
            },
            "open_action": {
              "url": "https://ya.ru"
            }
          }
        },
        "devices": [
          {
            "id_type": "appmetrica_device_id",
            "id_values": ["123456789", "42"]
          },
          {
            "id_type": "ios_ifa",
            "id_values": ["8A690667-6204-4A6A-9B38-85DE016....."]
          },
          {
            "id_type": "google_aid",
            "id_values": ["eb5f3ec8-2e3e-492f-b15b-d21860b....."]
          },
          {
            "id_type": "android_push_token",
            "id_values": ["eFfxdO7uCMw:APA91bF1tN3X3BAbiJXsQhk-..."]
          },
          {
            "id_type": "ios_push_token",
            "id_values": ["F6A79E9F844A24C5FBED5C58A4C71561C180F........."]
          },
          {
            "id_type": "huawei_push_token",
            "id_values": ["0866422030....."]
          },
          {
            "id_type": "huawei_oaid",
            "id_values": ["ecef47f7-fcce-ad....."]
          }
        ]
      },
      {
        "messages": {
        ...
        }
      }
    ]
  }
}
```
#|
|| `推送批量请求` | 批量推送消息请求 ||
|| `推送批处理请求.组 ID`* | 组 ID。 ||
|| `推送批处理请求.客户端传输ID` | 用户指定的发送 ID。 它用于[检查发送状态](https://boost.yandex.com/doc/zh/analytics/content/mobile-api/push/get-status-group-id.md)。

{% note alert %}

`client_transfer_id` 值在指定的组 (`group_id`) 中必须是唯一的。

{% endnote %}
||
|| `推送批处理请求标签`* | [发送标签](*发送标签) ||
|| `push_batch_request.批处理` | 数组`消息`对象。 它包含带有属性的推送消息。 ||
|| `推送批处理请求.批次.消息` | Push 消息。 ||
|| `推送批量请求.批次.消息.android` | 设备平台。 ||
|| `推送批处理请求.批次.消息.Android.静默` | 一个标志，表示[静默推送](*silent push)发送。 可能的取值：`true` | false`. ||
|| `推送批处理请求.批次.消息.Android.内容` | 推送消息的内容。 ||
|| `推送批量请求.批次.消息.安卓.内容.标题` | 推送消息的标题。 该值对于非静默推送消息是必填的。 ||
|| `推送批量请求.批次.消息.Android.内容.文本` | 消息文本。 该值对于非静默推送消息是必填的。 ||
|| `推送批处理请求.批次.消息.Android.内容.图标` | 图标显示在通知栏中。 默认情况下，会显示标准的应用图标。 要更改图标，请在标准 `/res/drawable/` 目录中设置图标资源 ID。 ||
|| `推送批量请求.批次.消息.Android.内容.图标背景` | 消息图标的颜色。 它以十六进制代码格式的字符串形式指定`#AARRGGBB`. ||
|| `推送批量请求.批次.消息.Android.内容.图像` | 推送消息中显示在通知文本旁边的图片的URL。 ||
|| `推送批处理请求.批次.消息.安卓.内容.横幅` | 推送消息中显示的图片的URL。 ||
|| `推送批处理请求.批次.消息.Android.内容.数据` | 任意数据字符串。 您可以将任何需要的数据作为字符串值传递。 您可以使用适当的Analytics module Push SDK 方法来处理数据字符串。 ||
|| `push_batch_request.batch.messages.android.content.渠道 ID` | 通知通道的ID。 如果未指定 ID，将使用默认通道。
适用于 Android 8 或更高版本。 要了解有关通道的更多信息，请参阅[Android 文档](https://developer.android.com/training/notify-user/channels)。 ||
|| `推送批处理请求.批次.消息.安卓.内容.优先级` | 通知优先级。 可接受的值范围是 `[-2; 2]`. 平台会根据消息的优先级采取相应措施：中断用户（在屏幕上显示消息），或者不通知用户有新消息。 在不同设备上，优先级的解释方式不同。 ||
|| `推送批处理请求_批次_消息_Android_内容_折叠键` | Notification ID. 默认值为 0。 如果当前应用程序没有显示推送通知，则忽略。 如果显示一个或多个通知，且新消息具有相同的通知 ID，则此通知的内容将被更新。 如果ID不同，会显示新消息。 ||
|| `推送批处理请求.批次.消息.Android.内容.振动` | 消息到来时的震动模式。 Format:  `[暂停时间（毫秒），振动时长（毫秒），暂停时间（毫秒），挣动时长（毫秒）……]`. ||
|| `push_batch_request.batch.messages.android.content.LED颜色` | LED颜色。 它以十六进制代码格式的字符串形式指定`#RRGGBB`. ||
|| `推送批量请求.批次.消息.Android.内容.LED间隔` | LED 指示灯亮起的持续时间（毫秒）。  ||
|| `push_batch_request.batch.messages.android.content.LED暂停间隔` | LED指示灯亮起的暂停时间（以毫秒为单位）。  ||
|| `推送批量请求.批次.消息.Android.内容.存活时间` | Firebase 在设备离线或不在范围内时存储推送消息的间隔时长（以秒为单位）。 ||
|| `推送批量请求.批次.消息.Android.内容.可见性` | 在锁屏上显示推送消息。 在 Android 8 及更高版本（API 级别 26+）中被忽略，因为设置是在频道级别完成的。 可接受的值：`secret`，`private`，`public`。 默认未设置。 要了解有关`可见性`属性的更多信息，请参阅[Android文档](https://developer.android.com/reference/android/app/Notification#VISIBILITY_PRIVATE) ||
|| `push_batch_request.批处理.消息.Android.内容.紧急程度` | 推送消息送达的紧急程度（优先级）。 可接受的值：`高`，`正常`. 默认值是`高`. 紧急推送消息会唤醒设备、在后台模式下启动应用，并短暂获得互联网访问权限。 紧急推送消息传递速度更快，可靠性更高。 要了解 [FCM 消息优先级](https://firebase.google.com/docs/cloud-messaging/concept-options#setting-the-priority-of-a-message) 的更多信息，请参阅 [Android 文档](https://developer.android.com/training/monitoring-device-state/doze-standby#using_fcm)。 ||
|| `推送批处理请求.批次.消息.Android.打开操作` | 用户点击推送通知时要执行的操作。 如果字段为空，用户点击将打开应用程序。 ||
|| `push_batch_request.batch.messages.android.open_action.深度链接` | 深链，用于在用户点击推送消息后将其导向应用屏幕。 ||
|| `推送批量请求.批次.消息.iOS` | 设备平台。 ||
|| `推送批量请求.批次.消息.ios.静默` | 一个标志，表示[静默推送](*silent push)发送。 可能的值：`true` | false`. ||
|| `推送_批次_请求.批次.消息.ios.内容` | 推送消息的内容。 ||
|| `推送批量请求.批次.消息.iOS.内容.标题` | 推送消息的标题。 该值对于非静默推送消息是必填的。 ||
|| `推送批量请求.批次.消息.iOS.内容.文本` | 消息文本。 该值对于非静默推送消息是必填的。 ||
|| `push_batch_request.batch.messages.ios.content.徽章` | 消息到达时在应用图标上显示的徽章数字。 ||
|| `推送批处理请求.批次.消息.iOS.内容.声音` | 消息音效。 可能的值：`default` | disable` ||
|| `push_batch_request.batch.messages.ios.content.线程ID` | 用于分组推送通知的ID。 该值指定在 [threadIdentifier](https://developer.apple.com/documentation/usernotifications/unmutablenotificationcontent/1649872-threadidentifier?language=objc) 属性中，属于 [UNNotificationContent](https://developer.apple.com/documentation/usernotifications/unnotificationcontent) 对象。 ||
|| `推送批处理请求.批次.消息.iOS.内容.类别` | Push 通知类别。 该值指定在 [标识符](https://developer.apple.com/documentation/usernotifications/unnotificationcategory/1649276-identifier?language=objc) 属性中，属于 `UNNotificationCategory` 对象。 有关推送操作和类别的更多信息，请参见[苹果文档](https://developer.apple.com/documentation/usernotifications/declaring_your_actionable_notification_types?language=objc)。 ||
|| `push_batch_request.批次.消息.iOS.内容.可变内容` | 表示通知服务扩展。 如果值是`1`，推送通知将由扩展程序处理。 Analytics module 使用它来跟踪推送通知的送达情况。

要跟踪发送，请设置[推送通知统计收集](LINK)，并将`1`作为字段值传入。 如果未指定值，报告中送达的推送通知数量将等于打开的消息数量。 ||
|| `推送批处理请求.批次.消息.iOS.内容.过期` | 向用户设备继续尝试发送通知的时长。 值应以秒为单位指定。
如果此时间已过而设备仍不可用（例如没有网络连接），通知将无法送达。 默认情况下，时间没有限制。 ||
|| `推送批量请求.批次.消息.iOS.内容.数据` | 一组任意的数据。 您可以将任何需要的数据作为字符串值传递。 您可以使用适当的Analytics module Push SDK 方法来处理数据字符串。 ||
|| `推送批量请求.批次.消息.iOS.内容.折叠标识` | 折叠 ID [apns-collapse-id](https://developer.apple.com/library/archive/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/CommunicatingwithAPNs.html#//apple_ref/doc/uid/TP40008194-CH11-SW12)。 具有相同 ID 的多个通知会显示为单个通知。 ||
|| `推送批量请求.批次.消息.iOS.内容.附件` | 要添加到推送消息中的附件数组。 详情请参阅文章 [步骤 6.（_可选_）配置上传附件](LINK). ||
|| `推送批量请求.批次.消息.iOS.内容.附件.标识` | 推送消息内容的ID。 ||
|| `推送批量请求.批次.消息.ios.内容.附件.file_url` | 推送消息中文件的URL。 ||
|| `推送批处理请求.批次.消息.ios.内容.附件.文件类型` | 推送消息中附件文件的类型。 关于可接受的类型，请参见[推送消息中的文件类型](https://boost.yandex.com/doc/zh/analytics/content/mobile-api/push/file-type.md)。 ||
|| `推送批处理请求.批次.消息.安卓.打开操作` | 用户点击推送通知时要执行的操作。 如果字段为空，用户点击将打开应用程序。 ||
|| `推送批处理请求.批次.消息.Android.打开操作.URL` | 点击推送消息时要跳转的 URL。 ||
|| `推送批量请求.批次.设备` | 要发送推送通知的设备。 每次消息发送可包含最多 250,000 台设备。
设备按 `id_type` 分组。 一次发送可以包含1到5个组。 每个 HTTP 请求中所有组最多可包含 250,000 台设备。 例如，如果 `appmetrica_device_id` 组包含 100,000 个设备，那么在其他组中只能指定 150,000 个。 ||
|| `推送批处理请求.批次.设备.ID类型` | ID 的类型。 可接受的值：`appmetrica_device_id`，`ios_ifa`，`google_aid`，`android_push_token`，`ios_push_token`，`huawei_push_token`，`huawei_oaid`.

{% note info %}

当您使用推送令牌作为标识符时，Analytics module 在发送前会检查数据库中是否存在令牌和设备信息。 如果没有设备信息，推送消息不会发送。 这是为了控制向指定收件人发送消息以及在报告中显示信息。

{% endnote %}
||
|| `推送批量请求.批次.设备.ID值` |要发送推送消息的设备列表。

{% note alert %}

列表不能为空。

{% endnote %} ||
|#

## 响应格式 {#response_format}

```json translate=no
{
  "push_response": {
    "transfer_id": 1,
    "client_transfer_id": long
  }
}
```

#|
|| `push_response` | 发送推送消息后的响应。 ||
|| `推送响应.传输ID` | 调度的ID。 它用于[检查分发状态](https://boost.yandex.com/doc/zh/analytics/content/mobile-api/push/get-status-id.md)。 ||
|| `推送响应.客户端传输ID` | 发送 ID，由用户在请求体中指定。 它用于[检查分发状态](https://boost.yandex.com/doc/zh/analytics/content/mobile-api/push/get-status-group-id.md)。

{% note info %}

该字段仅在请求体中指定时才会返回。

{% endnote %}
||
|#

<!-- source: zh/analytics/content/_includes/feedback-button-2.md -->
如果您没有找到所需答案，可以通过反馈表单提交您的问题。 请尽可能详细地描述问题。 如果可能，请附上截图。

<a href="../troubleshooting/feedback-new">
  <span class="button">联系支持</span>
</a>

<a href="../troubleshooting/feedback-docs">
  <span class="button">建议改进文档</span>
</a>
<!-- endsource: zh/analytics/content/_includes/feedback-button-2.md -->

[*The sending tag]: 标签是任意字符串，用于标识API执行的每次发送操作。 您可以用一个标签为任意数量的发送标记。 报告在第二级显示标签。

[*silent push]: 应用程序在后台处理的消息，不会显示给用户。 您可以通过静默推送消息向应用传输额外数据或检查通知的送达情况。