功能说明
开启推送插件后,推送结果可以通过配置基础回调的方式,将结果转发给 App 后台。
注意事项
该回调属于下行扩散后的事件回调,为防止大量回调请求打垮 App 后台,默认QPS:1000次/s。超频的回调会延迟一段时间重试,如果您因业务需求需要调整 QPS,可以 提交工单 申请。
要启用回调,必须配置回调 URL,并打开本回调对应的开关,配置方法详见 第三方回调配置 文档。
回调的方向是即时通信 IM 后台向 App 后台发起 HTTP POST 请求。
App 后台在收到回调请求之后,务必校验请求 URL 中的参数 SDKAppID 是否是自己的 SDKAppID。
其他安全相关事宜请参见 第三方回调简介:安全考虑 文档。
接口说明
请求 URL 示例
以下示例中 App 配置的回调 URL 为
https://www.example.com
示例:https://www.example.com?SdkAppid=$SDKAppID&CallbackCommand=$CallbackCommand&contenttype=json
请求参数说明
| 字段 | 说明 | 
| https | 请求协议为 HTTPS。 请求方式为 POST。 | 
| www.example.com | 回调 URL。 | 
| SdkAppid | 创建应用时在即时通信 IM 控制台分配的 SDKAppID。 | 
| CallbackCommand | 固定为:Push.OfflinePush。 | 
| contenttype | 请求包体固定为  json。 | 
请求包示例
{"Events": [ // events数组长度范围为1~100{"CallbackCommand":"Push.OfflinePush","EventType": 1, // 事件类型,EventType=1表示单聊"EventTime": 1557481127, // 事件发生时间戳, 单位为秒"From_Account": "user1", // 发送者"To_Account": "user2", // 接受者"PushPlatform": 1, // 推送厂商"PushStage": 1, // 推送阶段"MsgKey": "48374_2837546_1557481126", // 单聊消息的唯一标识"MsgSeq": 48374, // 消息序列号"MsgRandom": 2837546, // 消息随机数"MsgTime": 1557481126, // 消息的发送时间戳,单位为秒"PushID": "67120c46_6a4086c0_9bf5fb50_200002d1089b322_2000005d8d46421", // 推送唯一标识"ErrCode": 0, // 推送事件结果"ErrInfo": "OK" // 推送事件结果描述,可能为空},{"CallbackCommand":"Push.OfflinePush","EventType": 2, // 事件类型,EventType=2表示群聊"EventTime": 1557481127, // 事件发生时间戳, 单位为秒"From_Account": "user2", // 发送者"To_Account": "user3", // 接受者"PushPlatform": 1, // 推送厂商"PushStage": 1, // 推送阶段"GroupID": "@TGS#12DEVUDHQ", // 群聊的群组 ID"MsgSeq": 48375, // 消息序列号"MsgRandom": 2837546, // 消息随机数"MsgTime": 1557481126, // 消息的发送时间戳,单位为秒"PushID": "6710c631_85_392fcbcff_200000b2f2c6820_200002c869bfb81", // 推送唯一标识"ErrCode": 0, // 推送事件结果"ErrInfo": "OK" // 推送事件结果描述,可能为空},....]}
请求包字段说明
| 字段 | 类型 | 说明 | 
| Events | Array [ Event Object ] | 批量回调内容,最多包含100个回调事件(Event Object)的数据。 | 
Event Object结构
| 字段 | 类型 | 说明 | 
| CallbackCommand | String | 回调命令。 | 
| EventType | Integer | 事件类型: EventType = 1表示单聊。 EventType = 2表示群聊。 | 
| EventTime | Integer | 事件发生时间戳, 单位为秒。 | 
| From_Account | String | 消息发送者 UserID。 | 
| To_Account | String | 消息接收者 UserID。 | 
| PushPlatform | Integer | 推送厂商: PushPlatform = 0表示未知厂商。 PushPlatform = 1表示 Apple APNS 推送。 PushPlatform = 2表示小米推送。 PushPlatform = 3表示华为推送。 PushPlatform = 4表示 Google FCM 推送。 PushPlatform = 5表示魅族推送。 PushPlatform = 6表示 OPPO 推送。 PushPlatform = 7表示 vivo 推送。 PushPlatform = 8表示荣耀推送。 PushPlatform = 9表示鸿蒙推送。 | 
| PushStage | Integer | 推送阶段: PushStage = 1表示推送发送阶段。 PushStage = 2表示推送触达阶段。 PushStage = 3表示推送点击阶段。 | 
| MsgKey | String | 单聊消息的唯一标识,仅在 EventType = 1时有效。群聊时该字段为空。 | 
| GroupID | String | 群聊的群组 ID,仅在 EventType = 2时有效。单聊时该字段为空。 | 
| MsgSeq | Integer | 消息序列号,用于标记该条消息(32位无符号整数)。 | 
| MsgRandom | Integer | 消息随机数,用于标记该条消息(32位无符号整数)。群聊时该字段为空。 | 
| MsgTime | Integer | 消息的发送时间戳,单位为秒。 | 
| PushID | String | 推送唯一标识,可以用PushID在IM控制台查询推送下发情况。 | 
| ErrCode | Integer | 推送事件结果: ErrCode = 0表示成功。 ErrCode 非0表示失败。 | 
| ErrInfo | String | 推送事件结果描述,可能为空。 | 
应答包示例
{"ActionStatus": "OK","ErrorInfo": "","ErrorCode": 0 // 0为回调成功,1为回调出错}
应答包字段说明
| 字段 | 类型 | 说明 | 
| ActionStatus | String | 请求处理的结果: OK 表示处理成功。 FAIL 表示失败。 | 
| ErrorCode | Integer | 错误码。 | 
| ErrorInfo | String | 错误说明。 |