服务端 API
单聊在线推送前
在单聊在线推送前调整目标用户或推送策略。
触发时机
| 项目 | 说明 |
|---|---|
| 类型 | 前置回调 |
| 配置项 | beforeOnlinePush |
| 回调命令 | callbackBeforeOnlinePushCommand |
HTTP 请求
POST {WEBHOOK_ADDRESS}/callbackBeforeOnlinePushCommand
Content-Type: application/json
operationID: {OPERATION_ID}{
"callbackCommand": "callbackBeforeOnlinePushCommand",
"operationID": "operation_001",
"platformID": 1,
"platform": "",
"userIDList": ["user_001"],
"title": "",
"desc": "",
"ex": "",
"iOSPushSound": "",
"iOSBadgeCount": false,
"clientMsgID": "client_msg_001",
"sendID": "user_001",
"groupID": "group_001",
"contentType": 1,
"sessionType": 1,
"atUserIDList": ["user_001"],
"content": "{\"text\":\"hello\"}"
}请求体参数
| 参数名 | 是否必填 | 类型 | 说明 |
|---|---|---|---|
| callbackCommand | 是 | string | 回调命令,值与当前页面的回调命令一致。 |
| operationID | 是 | string | OpenIM 操作的链路追踪 ID。 |
| platformID | 是 | int | 客户端平台 ID,参见用户模块的 PlatformID。 |
| platform | 是 | string | 客户端平台名称。 |
| userIDList | 是 | string[] | 目标用户 ID 列表。 |
| title | 是 | string | 离线推送标题。 |
| desc | 是 | string | 离线推送摘要。 |
| ex | 是 | string | 业务扩展字段。 |
| iOSPushSound | 是 | string | iOS 推送提示音。 |
| iOSBadgeCount | 是 | boolean | 是否更新 iOS 角标。 |
| clientMsgID | 是 | string | 客户端消息 ID。 |
| sendID | 是 | string | 消息发送者用户 ID。 |
| groupID | 是 | string | 群组 ID。 |
| contentType | 是 | int | 消息内容类型,参见消息内容类型。 |
| sessionType | 是 | int | 会话类型,参见会话模块的 ConversationType。 |
| atUserIDList | 是 | string[] | 被 @ 的用户 ID 列表。 |
| content | 是 | string | 消息内容;通常是与消息类型对应的 JSON 字符串。 |
响应
业务服务端应返回 HTTP 成功状态和 JSON 响应体。
{
"actionCode": 0,
"errCode": 0,
"errMsg": "",
"errDlt": "",
"nextCode": 0,
"userIDList": ["user_001"],
"offlinePushInfo": {}
}响应参数
| 参数名 | 类型 | 说明 |
|---|---|---|
| actionCode | int | 处理状态,参见Webhooks 概述的 CallbackAction。 |
| errCode | int | 业务错误码;拒绝前置操作时返回业务约定的非零错误码。 |
| errMsg | string | 错误简要信息。 |
| errDlt | string | 错误详细信息。 |
| nextCode | int | 处理下一步,参见Webhooks 概述的 CallbackNextCode。 |
| userIDList | string[] | 目标用户 ID 列表。 |
| offlinePushInfo | object | 离线推送配置。 |
处理规则
- OpenIM 同步等待业务服务端响应。
- 返回
nextCode: 0时继续原流程;返回nextCode: 1时,OpenIM 使用响应中的错误信息终止本次操作。 - 请求失败或超时后的行为由该回调的
failedContinue配置决定。 - 响应中的业务字段仅在对应字段存在时覆盖 OpenIM 即将处理的数据。
相关页面
这个页面有帮助吗?