Skip to main content

Callback Before Online Push Message

Functional Description

Before an online message is pushed to the client, the App business server can receive a request to push the message through this callback. The business server can intercept, modify, or add additional push information to the message as needed.

Precautions

  • To enable the callback, you must configure the callback URL and turn on the switch corresponding to this callback protocol. See the Callback Description document for configuration methods.
  • The callback direction is an HTTP/HTTPS POST request initiated by OpenIMServer to the App backend.
  • After receiving the callback request, the App business server must respond within the timeout period.

Scenarios That May Trigger This Callback

  • Group member quits the group.
  • Group member is kicked out of the group.
  • Group is dismissed.

Timing of Callback

  • Before OpenIMServer prepares to push a message to the client.

Interface Description

Request URL Example

Here CallbackCommand is: callbackBeforeOnlinePushCommand

{WEBHOOK_ADDRESS}/callbackBeforeOnlinePushCommand?contenttype=json

Request Package Example

{
"callbackCommand": "callbackBeforeOnlinePushCommand",
"platformID": 1,
"platform": "iOS",
"userIDList": ["user123", "user456"],
"title": "New Message",
"desc": "You have a new message",
"ex": "Extra push info",
"iOSPushSound": "default",
"iOSBadgeCount": true,
"signalInfo": "Signal data",
"clientMsgID": "msg123",
"sendID": "user789",
"groupID": "group123",
"contentType": 1,
"sessionType": 2,
"atUserIDList": ["user101", "user102"],
"content": "Hello, this is a test message"
}

Request Package Field Description

FieldTypeDescription
callbackCommandstringCallback command, here it is the callback before online message push
platformIDintPlatform ID (e.g., 1 for iOS, 2 for Android)
platformstringPlatform name (e.g., iOS, Android)
userIDListarrayList of user IDs indicating which users will receive this message
titlestringTitle of the push message
descstringDescription or body content of the push message
exstringAdditional push information
iOSPushSoundstringSound used when pushing message on iOS devices
iOSBadgeCountbooleanWhether to modify the unread message count on the iOS app icon
signalInfostringAdditional signal data used to pass extra info
clientMsgIDstringClient message ID
sendIDstringSender ID
groupIDstringGroup ID (if the message is sent to a group)
contentTypeintMessage content type ID
sessionTypeintSession type ID
atUserIDListarrayList of IDs of users being @'ed
contentstringContent of the sent message

Response Package Example

Allow Pushing

Allow the message to be pushed to the client.

{
"actionCode": 0,
"errCode": 0,
"errMsg": "",
"errDlt": "",
"nextCode": "",
"userIDList": ["user123", "user456"],
"offlinePushInfo": {
"title": "New Message",
"desc": "You have a new message",
"ex": "Extra push info",
"iOSPushSound": "default",
"iOSBadgeCount": true,
"signalInfo": "Signal data"
}
}

Response Package Field Description

FieldTypeDescription
actionCode0Indicates whether the business system callback was executed correctly. 0 means the operation was successful.
errCode5001Custom error code, ranges from 5000-9999. Set when actionCode is not 0; set when nextCode is 1.
errMsg"An error message"Simple error message corresponding to the custom error code.
errDlt"Detailed error information"Detailed error information corresponding to the custom error code.
nextCode1Next execution instruction, 1 means refusing to continue execution, set when actionCode is 0.
userIDListarrayList of user IDs, indicating users allowed to receive the message.
offlinePushInfoobjectOffline push info object.