This API is used to add the callback function for receiving new messages.
Prototype
TIM_DECL void TIMAddRecvNewMsgCallback(TIMRecvNewMsgCallback cb, const void* user_data);
Parameters
Parameter | Type | Description |
---|---|---|
cb | TIMRecvNewMsgCallback | New message callback function. For more information, see TIMRecvNewMsgCallback. |
user_data | const void* | User-defined data. The Chat SDK only transfers the user data to the callback function cb without processing the data. |
Note:If a user has logged in, the Chat SDK will send new messages using the callback function set by this API. New messages include not only unread messages but also any messages that do not exist on the local terminal. For example, when the Chat SDK fetches recent contact messages, the last message in the conversation can be obtained. If the message does not exist on the local terminal, it will be sent using this method. After the user logs in, the Chat SDK will fetch offline messages. In order not to miss message notifications, the user needs to register new message notifications before login.
This API is used to delete the callback function for receiving new messages.
Prototype
TIM_DECL void TIMRemoveRecvNewMsgCallback(TIMRecvNewMsgCallback cb);
Parameters
Parameter | Type | Description |
---|---|---|
cb | TIMRecvNewMsgCallback | New message callback function. For more information, see TIMRecvNewMsgCallback. |
Note:The
cb
parameter must be the same as that sent by TIMAddRecvNewMsgCallback. Otherwise, the callback function cannot be deleted.
This API is used to set the callback function for message read receipts.
Prototype
TIM_DECL void TIMSetMsgReadedReceiptCallback(TIMMsgReadedReceiptCallback cb, const void* user_data);
Parameters
Parameter | Type | Description |
---|---|---|
cb | TIMMsgReadedReceiptCallback | Callback function for message read receipts. For more information, see TIMMsgReadedReceiptCallback. |
user_data | const void* | User-defined data. The Chat SDK only transfers the user data to the callback function cb without processing the data. |
Note:When the sender sends a message, the recipient calls the TIMMsgReportReaded API to report that the message has been read or calls the TIMMsgSendMessageReadReceipts API to send group message read receipts. The Chat SDK at the sender's end will send the receipts through the callback set by this API.
This API is used to set the callback function for notifying received message recall.
Prototype
TIM_DECL void TIMSetMsgRevokeCallback(TIMMsgRevokeCallback cb, const void* user_data);
Parameters
Parameter | Type | Description |
---|---|---|
cb | TIMMsgRevokeCallback | Callback function for notifying received message recall. For more information, see TIMMsgRevokeCallback. |
user_data | const void* | User-defined data. The Chat SDK only transfers the user data to the callback function cb without processing the data. |
Note:If the sender calls the TIMMsgRevoke API to recall a message that is sent to the recipient, the Chat SDK at the recipient's end will send a message recall notification using the callback function set by this API.
This API is used to set the callback function for updating message extensions.
Prototype
TIM_DECL void TIMSetMsgExtensionsChangedCallback(TIMMsgExtensionsChangedCallback cb, const void* user_data);
Parameters
Parameter | Type | Description |
---|---|---|
cb | TIMMsgExtensionsChangedCallback | Callback function for updating message extensions. For more information, see TIMMsgExtensionsChangedCallback. |
user_data | const void* | User-defined data. The Chat SDK only transfers the user data to the callback function cb without processing the data. |
This API is used to set the callback function for deleting message extensions.
Prototype
TIM_DECL void TIMSetMsgExtensionsDeletedCallback(TIMMsgExtensionsDeletedCallback cb, const void* user_data);
Parameters
Parameter | Type | Description |
---|---|---|
cb | TIMMsgExtensionsDeletedCallback | Callback function for deleting message extensions. For more information, see TIMMsgExtensionsDeletedCallback. |
user_data | const void* | User-defined data. The Chat SDK only transfers the user data to the callback function cb without processing the data. |
This API is used to set the callback function for the upload progress of message element files.
Prototype
TIM_DECL void TIMSetMsgElemUploadProgressCallback(TIMMsgElemUploadProgressCallback cb, const void* user_data);
Parameters
Parameter | Type | Description |
---|---|---|
cb | TIMMsgElemUploadProgressCallback | Callback function for file upload progress. For more information, see TIMMsgElemUploadProgressCallback. |
user_data | const void* | User-defined data. The Chat SDK only transfers the user data to the callback function cb without processing the data. |
Note:Set the callback function for the message element upload progress. When a message contains image, voice, file, and video elements, the Chat SDK will upload these files and trigger the callback function set by this API. Users can detect the upload progress based on the callback function.
This API is used to set the callback function for group attribute changes.
Prototype
TIM_DECL void TIMSetGroupAttributeChangedCallback(TIMGroupAttributeChangedCallback cb, const void* user_data);
Parameters
Parameter | Type | Description |
---|---|---|
cb | TIMGroupAttributeChangedCallback | The callback function for group attribute changes. For more information, see TIMGroupAttributeChangedCallback. |
user_data | const void* | User-defined data. The Chat SDK only transfers the user data to the callback function cb without processing the data. |
Note:If the attributes of a group you have joined are modified, all attributes of the group are returned (all members of the group can receive them).
This API is used to set the callback function for group counter changes.
Prototype
TIM_DECL void TIMSetGroupCounterChangedCallback(TIMGroupCounterChangedCallback cb, const void* user_data);
Parameters
Parameter | Type | Description |
---|---|---|
cb | TIMGroupCounterChangedCallback | Callback function for group counter changes. For more information, see TIMGroupCounterChangedCallback. |
user_data | const void* | User-defined data. The Chat SDK only transfers the user data to the callback function cb without processing the data. |
Note:If the counters of a group that you have joined are modified, the new group counter values are returned to all members of the group.
This API is used to set the callback function for group system messages.
Prototype
TIM_DECL void TIMSetGroupTipsEventCallback(TIMGroupTipsEventCallback cb, const void* user_data);
Parameters
Parameter | Type | Description |
---|---|---|
cb | TIMGroupTipsEventCallback | Group message callback function. For more information, see TIMGroupTipsEventCallback. |
user_data | const void* | User-defined data. The Chat SDK only transfers the user data to the callback function cb without processing the data. |
Note:Group system message events include joining a group, leaving a group, being kicked out of a group, setting an admin, canceling an admin, modifying group information, and modifying group member information. These messages are sent to all group members.
This API is used to set the callback function for conversation events.
Prototype
TIM_DECL void TIMSetConvEventCallback(TIMConvEventCallback cb, const void* user_data);
Parameters
Parameter | Type | Description |
---|---|---|
cb | TIMConvEventCallback | Conversation event callback function. For more information, see TIMConvEventCallback. |
user_data | const void* | User-defined data. The Chat SDK only transfers the user data to the callback function cb without processing the data. |
Note:
This API is used to set the callback function for unread message count updates of all conversations.
Prototype
TIM_DECL void TIMSetConvTotalUnreadMessageCountChangedCallback(TIMConvTotalUnreadMessageCountChangedCallback cb, const void* user_data);
Parameters
Parameter | Type | Description |
---|---|---|
cb | TIMConvTotalUnreadMessageCountChangedCallback | Callback function for unread message count updates of all conversations. For more information, see TIMConvTotalUnreadMessageCountChangedCallback. |
user_data | const void* | User-defined data. The Chat SDK only transfers the user data to the callback function cb without processing the data. |
Note:
kTIMRecvMsgOpt_Not_Receive
or kTIMRecvMsgOpt_Not_Notify
.This API is used to set the callback function for the unread message count updates by conversation filter.
Prototype
TIM_DECL void TIMSetConvUnreadMessageCountChangedByFilterCallback(TIMConvTotalUnreadMessageCountChangedByFilterCallback cb, const void* user_data);
Parameters
Parameter | Type | Description |
---|---|---|
cb | TIMConvTotalUnreadMessageCountChangedByFilterCallback | Callback function for updates of the unread message count by conversation filter. For more information, see TIMConvTotalUnreadMessageCountChangedByFilterCallback. |
user_data | const void* | User-defined data. The Chat SDK only transfers the user data to the callback function cb without processing the data. |
Note:
subscribeUnreadMessageCountByFilter
to register for the listening to the changes of the total unread message count under specified filters. The Chat SDK notifies you of the latest unread message count through this callback.filter
parameter in the callback lists the filters specified when you register for the listening. The filter
parameter contains the kTIMConversationListFilterConvType
, kTIMConversationListFilterMarkType
, and kTIMConversationListFilterGroupName
fields. Filters are distinguished by the values of these three fields.kTIMRecvMsgOpt_Not_Receive
or kTIMRecvMsgOpt_Not_Notify
.This API is used to set the callback function for monitoring the network connection status.
Prototype
TIM_DECL void TIMSetNetworkStatusListenerCallback(TIMNetworkStatusListenerCallback cb, const void* user_data);
Parameters
Parameter | Type | Description |
---|---|---|
cb | TIMNetworkStatusListenerCallback | Network connection event callback function. For more information, see TIMNetworkStatusListenerCallback. |
user_data | const void* | User-defined data. The Chat SDK only transfers the user data to the callback function cb without processing the data. |
Note:
This API is used to set the callback function for kicked-offline notifications.
Prototype
TIM_DECL void TIMSetKickedOfflineCallback(TIMKickedOfflineCallback cb, const void* user_data);
Parameters
Parameter | Type | Description |
---|---|---|
cb | TIMKickedOfflineCallback | Callback function when the user is kicked offline. For more information, see TIMKickedOfflineCallback. |
user_data | const void* | User-defined data. The Chat SDK only transfers the user data to the callback function cb without processing the data. |
Note:
TIMKickedOfflineCallback
. After the user receives the callback on device 1, the system prompts that the user can call login to log in on device 1 and kick device 2 offline.ERR_IMSDK_KICKED_BY_OTHERS: 6208
when the user logs in on device 1 again. This error code indicates that the user was kicked offline the last time and allows the user to determine whether to go offline on the other device. If yes, the user can call login again to log in forcibly, and the instance online on device 2 will receive TIMKickedOfflineCallback
.This API is used to set the callback function for ticket expiration.
Prototype
TIM_DECL void TIMSetUserSigExpiredCallback(TIMUserSigExpiredCallback cb, const void* user_data);
Parameters
Parameter | Type | Description |
---|---|---|
cb | TIMUserSigExpiredCallback | Ticket expiration callback function. For more information, see TIMUserSigExpiredCallback. |
user_data | const void* | User-defined data. The Chat SDK only transfers the user data to the callback function cb without processing the data. |
Note:User tickets may expire. If a user ticket expires, the callback function set by this API will be called. TIMLogin will return error code 70001. Developers can change the ticket based on the error code or ticket expiration callback function.
This API is used to set the callback function for adding friends.
Prototype
TIM_DECL void TIMSetOnAddFriendCallback(TIMOnAddFriendCallback cb, const void* user_data);
Parameters
Parameter | Type | Description |
---|---|---|
cb | TIMOnAddFriendCallback | Callback function for adding friends. For more information, see TIMOnAddFriendCallback. |
user_data | const void* | User-defined data. The Chat SDK only transfers the user data to the callback function cb without processing the data. |
Note:This callback function is used for multi-terminal synchronization. For example, the same Chat SDK account has logged in to devices A and B. When device A adds a friend, the Chat SDK on device B will receive a friend addition notification, and the Chat SDK will notify the developer using this callback function.
This API is used to set the callback function for deleting friends.
Prototype
TIM_DECL void TIMSetOnDeleteFriendCallback(TIMOnDeleteFriendCallback cb, const void* user_data);
Parameters
Parameter | Type | Description |
---|---|---|
cb | TIMOnDeleteFriendCallback | Callback function for deleting friends. For more information, see TIMOnDeleteFriendCallback. |
user_data | const void* | User-defined data. The Chat SDK only transfers the user data to the callback function cb without processing the data. |
Note:This callback function is used for multi-terminal synchronization. For example, the same Chat SDK account has logged in to devices A and B. When device A deletes a friend, the Chat SDK on device B will receive a friend deletion notification, and the Chat SDK will notify the developer using this callback function.
This API is used to set the callback function for updating friend profiles.
Prototype
TIM_DECL void TIMSetUpdateFriendProfileCallback(TIMUpdateFriendProfileCallback cb, const void* user_data);
Parameters
Parameter | Type | Description |
---|---|---|
cb | TIMUpdateFriendProfileCallback | Callback function for updating friend profiles. For more information, see TIMUpdateFriendProfileCallback. |
user_data | const void* | User-defined data. The Chat SDK only transfers the user data to the callback function cb without processing the data. |
Note:This callback function is used for multi-terminal synchronization. For example, the same Chat SDK account has logged in to devices A and B. When device A updates a friend's profile, the Chat SDK on device B will receive a friend profile update notification, and the Chat SDK will notify the developer using this callback function.
This API is used to set the callback function for friend requests.
Prototype
TIM_DECL void TIMSetFriendAddRequestCallback(TIMFriendAddRequestCallback cb, const void* user_data);
Parameters
Parameter | Type | Description |
---|---|---|
cb | TIMFriendAddRequestCallback | Callback function for friend requests. For more information, see TIMFriendAddRequestCallback. |
user_data | const void* | User-defined data. The Chat SDK only transfers the user data to the callback function cb without processing the data. |
Note:If the logged-in user has set confirmation for friend requests and another user sends a friend request to this user, the logged-in user will receive the friend request callback, and the Chat SDK will notify the developer using this callback function. If the same account has logged in on multiple terminals, each terminal will receive the callback.
This API is used to set the callback function for friend request deletion.
Prototype
TIM_DECL void TIMSetFriendApplicationListDeletedCallback(TIMFriendApplicationListDeletedCallback cb, const void* user_data);
Parameters
Parameter | Type | Description |
---|---|---|
cb | TIMFriendApplicationListDeletedCallback | Callback function for friend request deletion. For more information, see TIMFriendApplicationListDeletedCallback. |
user_data | const void* | User-defined data. The Chat SDK only transfers the user data to the callback function cb without processing the data. |
Note:
This API is used to set the callback function for friend request read notifications.
Prototype
TIM_DECL void TIMSetFriendApplicationListReadCallback(TIMFriendApplicationListReadCallback cb, const void* user_data);
Parameters
Parameter | Type | Description |
---|---|---|
cb | TIMFriendApplicationListReadCallback | Callback function for friend request read notifications. For more information, see TIMFriendApplicationListReadCallback. |
user_data | const void* | User-defined data. The Chat SDK only transfers the user data to the callback function cb without processing the data. |
Note:If you call
setFriendApplicationRead
to set the friend request list as read, you will receive this callback (mainly used for multi-device synchronization).
This API is used to set the callback function for adding a user to the blocklist.
Prototype
TIM_DECL void TIMSetFriendBlackListAddedCallback(TIMFriendBlackListAddedCallback cb, const void* user_data);
Parameters
Parameter | Type | Description |
---|---|---|
cb | TIMFriendBlackListAddedCallback | Callback function for adding a user to the blocklist. For more information, see TIMFriendBlackListAddedCallback. |
user_data | const void* | User-defined data. The Chat SDK only transfers the user data to the callback function cb without processing the data. |
This API is used to set the callback function for removing a user from the blocklist.
Prototype
TIM_DECL void TIMSetFriendBlackListDeletedCallback(TIMFriendBlackListDeletedCallback cb, const void* user_data);
Parameters
Parameter | Type | Description |
---|---|---|
cb | TIMFriendBlackListDeletedCallback | Callback function for removing a user from the blocklist. For more information, see TIMFriendBlackListDeletedCallback. |
user_data | const void* | User-defined data. The Chat SDK only transfers the user data to the callback function cb without processing the data. |
This API is used to set the callback function for logs.
Prototype
TIM_DECL void TIMSetLogCallback(TIMLogCallback cb, const void* user_data);
Parameters
Parameter | Type | Description |
---|---|---|
cb | TIMLogCallback | Log callback. For more information, see TIMLogCallback. |
user_data | const void* | User-defined data. The Chat SDK only transfers the user data to the callback function cb without processing the data. |
Note:After the log monitoring callback function is set, the Chat SDK internal logs will be returned to the callback function set by this API. Developers can call the TIMSetConfig API to configure the log levels of logs to be returned to the callback function.
This API is used to set the callback function for message update notifications returned after messages are modified on the cloud.
Prototype
TIM_DECL void TIMSetMsgUpdateCallback(TIMMsgUpdateCallback cb, const void* user_data);
Parameters
Parameter | Type | Description |
---|---|---|
cb | TIMMsgUpdateCallback | Message update callback function. For more information, see TIMMsgUpdateCallback. |
user_data | const void* | User-defined data. The Chat SDK only transfers the user data to the callback function cb without processing the data. |
Note:
Was this page helpful?