AddRecvNewMsgCallback
introduction
Add receiving new message callback
If logged in, ImSDK will retrieve messages send to you. PS. It doesn't have to be the unread messages
Only messages that aren't stored in the local storage will be retrieved. (Eg. Message read from other platform, and retrieve latest conversation's last message, if it's not in the local storage, the message will appear in here)
Once logged in, ImSDK will retrieve offline messages. Register this callback before log in to prevent missing messages
The receiver can receive message by using a message listener in the following steps:
Call AddRecvNewMsgCallback to set the event listener.
Listen for the RecvNewMsgCallback callback to receive text messages.
To stop receiving messages, call RemoveRecvNewMsgCallback to remove the listener. This step is optional and can be performed as needed.
Parameter details
Parameter name | Parameter type | Required | Description |
---|---|---|---|
callback | RecvNewMsgCallback | no | RecvNewMsgCallback |
stringCallback | RecvNewMsgStringCallback | no | RecvNewMsgStringCallback |
Returned template
TIMResult
The parameters of the callback function after successfully calling the API:
code:int
desc:string
json_param:'' // json_ Params is an empty string ""
user_data:string
Return value details
name | type | description |
---|---|---|
TIMResult | TIMResult | Return value of calling API |
code | int | Result error code: Error Codes |
desc | string | The description of the error. |
json_param | string | Json string. Calling different API will get different Json strings. |
user_data | string | User-defined data transfered by ImSDK without any processing |