Other Push Callbacks
Feature Description
After enabling the push plugin, the push results can be forwarded to the app backend by configuring the basic callback.
Notes
To enable this callback, you must configure the callback URL and enable the corresponding switch for this callback. For more information on the configuration method, see Webhooks documentation.
During this callback, the IM backend initiates an HTTP POST request to the app backend.
After receiving the callback request, the app backend must check whether the SDKAppID contained in the request URL is consistent with its own SDKAppID.
For additional safety-related concerns, please refer to the Third-Party Callback Overview: Security Considerations document.
API Description
Request URL sample:
In the following example, the callback URL configured in the App configuration is
https://www.example.com
Example:
https://www.example.com?SdkAppid=$SDKAppID&CallbackCommand=$CallbackCommand&contenttype=json
Request parameters
Field | Description |
https | Request protocol is HTTPS Request method is POST |
www.example.com | Callback URL |
SdkAppid | SDKAppID allocated by the Instant Messaging console at the time of Application creation |
CallbackCommand | Fixed as: Push.OfflinePush |
contenttype | The request payload is fixed as JSON |
Sample request packets
{"Events": [ // The length of the events array ranges from 1 to 100{"CallbackCommand":"Push.OfflinePush","EventType": 1, // Event type, EventType=1 indicates single chat"EventTime": 1557481127, // Event timestamp in seconds"From_Account": "user1", // Sender"To_Account": "user2", // Recipient"PushPlatform": 1, // Vendor"PushStage": 1, // Push stage"MsgKey": "48374_2837546_1557481126", // Unique identifier of the single chat message"MsgSeq": 48374, // Sequence number of the message"MsgRandom": 2837546, // Random number of the message"MsgTime": 1557481126, // Timestamp in seconds indicating when the message is sent"PushID": "67120c46_6a4086c0_9bf5fb50_200002d1089b322_2000005d8d46421", // Unique identifier of the push"ErrCode": 0, // Push event result"ErrInfo": "OK" // Push event result description, may be empty},{"CallbackCommand":"Push.OfflinePush","EventType": 2, // Event type, EventType=2 indicates group chat"EventTime": 1557481127, // Event timestamp in seconds"From_Account": "user2", // Sender"To_Account": "user3", // Recipient"PushPlatform": 1, // Vendor"PushStage": 1, // Push stage"GroupID": "@TGS#12DEVUDHQ", // Group chat ID"MsgSeq": 48375, // Sequence number of the message"MsgRandom": 2837546, // Random number of the message"MsgTime": 1557481126, // Timestamp in seconds indicating when the message is sent"PushID": "6710c631_85_392fcbcff_200000b2f2c6820_200002c869bfb81", // Unique identifier of the push"ErrCode": 0, // Push event result"ErrInfo": "OK" // Push event result description, may be empty},....]}
Request packet fields
Field | Type | Description |
Events | Array [ Event Object ] | Batch callback content, containing data for up to 100 callback events (Event Object) |
Event Object Structure
Field | Type | Description |
CallbackCommand | String | Callback command |
EventType | Integer | Event Type: EventType = 1 indicates single chat EventType = 2 indicates group chat |
EventTime | Integer | Event timestamp in seconds |
From_Account | String | Message Sender UserID |
To_Account | String | Recipient's UserID |
PushPlatform | Integer | Vendor: PushPlatform = 0 indicates unknown vendor PushPlatform = 1 indicates Apple APNS push PushPlatform = 2 indicates Xiaomi push PushPlatform = 3 indicates Huawei push PushPlatform = 4 indicates Google FCM push PushPlatform = 5 indicates Meizu push PushPlatform = 6 indicates OPPO push PushPlatform = 7 indicates vivo push PushPlatform = 8 indicates Honor push |
PushStage | Integer | Push stage: PushStage = 1 indicates push sending stage PushStage = 2 indicates push delivery stage PushStage = 3 indicates push click stage |
MsgKey | String | The unique identifier of a single chat message, valid only when EventType = 1. This field is empty for group chats. |
GroupID | String | Group ID for group chats, valid only when EventType = 2. This field is empty for single chats. |
MsgSeq | Integer | Message serial number, utilized for marking the respective message (32-bit unsigned integer) |
MsgRandom | Integer | Message random number used to mark the message (32-bit unsigned integer). This field is empty for group chats. |
MsgTime | Integer | Message sending timestamp in seconds |
PushID | String | Unique identifier of the push, can be used to query push delivery status in the IM console with PushID |
ErrCode | Integer | Push event result: ErrCode = 0 indicates success ErrCode non-zero indicates failure |
ErrInfo | String | Push event result description, may be empty |
Response packet example
{"ActionStatus": "OK","ErrorInfo": "","ErrorCode": 0 // 0 means callback success, 1 means callback error}
Response packet field description
Field | Type | Description |
ActionStatus | String | Processed Request Result: OK Signifies Successful Handling FAILURE signifies unsuccessful execution |
ErrorCode | Integer | Error Code |
ErrorInfo | String | Error Description |