Skip to main content

Delete Conversation

Delete a Specific Conversation

  • Removes a specific conversation from the conversation list without deleting the messages within the conversation.
  • If a new message is received in the conversation, previous messages will still be available for the user to view.
  • If you need to remove a specific conversation and delete the messages within it, please call the interface to delete messages within the conversation simultaneously.

Method


removeConversation(
type: RCIMIWConversationType,
targetId: string,
channelId: string,
callback: IRCIMIWRemoveConversationCallback
): Promise<number>;

Parameter Description

ParameterTypeDescription
typeRCIMIWConversationTypeConversation type
targetIdstringConversation ID
channelIdstringChannel ID, only supported for ultra groups. For other conversation types, pass null.
callbackIRCIMIWRemoveConversationCallbackCallback for the interface call result.

Return Value

Return ValueDescription
numberStatus code of the current interface operation. 0 indicates a successful call. Specific results need to be implemented in the interface callback. Non-zero indicates that the current interface call operation failed, and the interface callback will not be triggered. Refer to the error code for detailed errors.

Code Example


const callback = {
onConversationRemoved: (code: number) => {
//...
},
};
let code = await engine.removeConversation(type, targetId, channelId, callback);

Delete Conversations by Type

Deletes conversations of the specified type and removes the messages within those conversations.

Method


removeConversations(
conversationTypes: Array<RCIMIWConversationType>,
channelId: string,
callback: IRCIMIWRemoveConversationsCallback
): Promise<number>;

Parameter Description

ParameterTypeDescription
conversationTypesArray<RCIMIWConversationType>Collection of conversation types
channelIdstringChannel ID, only supported for ultra groups. For other conversation types, pass null.
callbackIRCIMIWRemoveConversationsCallbackCallback for the interface call result.

Return Value

Return ValueDescription
numberStatus code of the current interface operation. 0 indicates a successful call. Specific results need to be implemented in the interface callback. Non-zero indicates that the current interface call operation failed, and the interface callback will not be triggered. Refer to the error code for detailed errors.

Code Example


const callback = {
onConversationsRemoved: (code: number) => {
//...
},
};
let code = await engine.removeConversations(conversationTypes, channelId, callback);

Delete All Conversations

The SDK does not have a built-in method to clear all conversations. You can use Delete Conversations by Type and pass in all conversation types.

This method will delete both the conversations and the messages. For chatrooms and ultra groups, it is recommended to display them separately in the UI layer, so they can be excluded when deleting.

Code Example

engine.removeConversations(
[RCIMIWConversationType.private, RCIMIWConversationType.group, RCIMIWConversationType.system],
channelId
)
.then((code: number) => {});