Event Callback APIs

Last updated: 2021-01-05 10:10:57

    TIMAddRecvNewMsgCallback

    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 IM SDK only transfers the user data to the callback function cb without processing the data.

    Note:

    If a user has logged in, the IM 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 IM 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 IM SDK will fetch offline messages. In order not to miss message notifications, the user needs to register new message notifications before login.

    TIMRemoveRecvNewMsgCallback

    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.

    TIMSetMsgReadedReceiptCallback

    This API is used to set the callback function for message read receipt.

    Prototype

    TIM_DECL void TIMSetMsgReadedReceiptCallback(TIMMsgReadedReceiptCallback cb, const void* user_data);

    Parameters

    Parameter Type Description
    cb TIMMsgReadedReceiptCallback Message read receipt callback function. For more information, see TIMMsgReadedReceiptCallback.
    user_data const void* User-defined data. The IM 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. The IM SDK at the sender's end will send the receipt using the callback function set by this API.

    TIMSetMsgRevokeCallback

    This API is used to set the callback function for notifying received message revocation.

    Prototype

    TIM_DECL void TIMSetMsgRevokeCallback(TIMMsgRevokeCallback cb, const void* user_data);

    Parameters

    Parameter Type Description
    cb TIMMsgRevokeCallback Message revocation notification callback function. For more information, see TIMMsgRevokeCallback.
    user_data const void* User-defined data. The IM SDK only transfers the user data to the callback function cb without processing the data.

    Note:

    If the sender calls the TIMMsgRevoke API to revoke a message that it sends to the recipient, the IM SDK at the recipient's end will send a message revocation notification using the callback function set by this API.

    TIMSetMsgElemUploadProgressCallback

    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 File upload progress callback function. For more information, see TIMMsgElemUploadProgressCallback.
    user_data const void* User-defined data. The IM 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 picture, voice, file, and video elements, the IM 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.

    TIMSetGroupTipsEventCallback

    This API is used to set the callback 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 IM SDK only transfers the user data to the callback function cb without processing the data.

    Note:

    Group system message events include joining a group, exiting a group, removing from a group, setting an admin, canceling an admin, changing group information, and changing group member information. These messages are sent to all group members.

    TIMSetConvEventCallback

    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 IM SDK only transfers the user data to the callback function cb without processing the data.

    Note:

    • Conversation events include:
      • Conversation creation
      • Conversation deletion
      • Conversation update
    • Any operation that generates a new conversation will trigger the conversation creation event, such as calling the TIMConvCreate API to create a c