Skip to main content

Callback Before Offline Push Message

Functional Description

Before an offline push message is sent to the client, the App business server can receive a request to send 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 OpenIM Server 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 send an offline push message to the client.

Interface Description

Request URL Example

Here CallbackCommand is: callbackBeforeOfflinePushCommand

{WEBHOOK_ADDRESS}/callbackBeforeOfflinePushCommand?contenttype=json

Request Package Example

{
"callbackCommand": "callbackBeforeOfflinePushCommand",
"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 offline 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 of the push message
exstringAdditional push information
iOSPushSoundstringSound setting when pushed on iOS
iOSBadgeCountboolWhether to modify the unread message count on the iOS app icon
signalInfostringAdditional signal information carried by the push
clientMsgIDstringClient message ID
sendIDstringUser ID of the sender
groupIDstringGroup ID, if it is a group message
contentTypeintType of message content
sessionTypeintSession type (e.g., 1 for single chat, 2 for group chat)
atUserIDListarrayList of IDs of users being @'ed
contentstringContent of the sent message

Response Package Example

Allow Pushing

Allow the message to be offline 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.