Skip to main content

Delete Conversation

App users may need to delete one or more conversations from the conversation list, which can be achieved through the SDK's delete conversation feature. The conversation list on the client is generated based on local messages, and deleting a conversation refers to deleting the local conversation.

Delete a Specific Conversation

Calling removeConversation achieves a soft delete effect. This interface does not actually delete the messages within the conversation but only removes the conversation item from the SDK's conversation list. After successfully deleting the conversation, the App can refresh the UI to no longer display the conversation item to the user.

BOOL success = [[RCIMClient sharedRCIMClient] removeConversation:ConversationType_PRIVATE
targetId:@"targetId"];
ParameterTypeDescription
conversationTypeRCConversationTypeConversation type, for one-to-one chat, pass ConversationType_PRIVATE
targetIdNSStringConversation ID

If a new message arrives in the conversation, the conversation will reappear in the conversation list, allowing the App user to view the historical and latest messages within the conversation.

The SDK does not provide an interface to simultaneously delete a specific conversation item and its historical messages. If you need to delete both, you can call the delete message interface while deleting the specified conversation. For details, see Delete Message.

Delete Conversations by Type

App users may need to clear all conversations of a certain type, such as clearing all group chat conversations. The SDK supports clearing all conversations and conversation information of specified types, allowing multiple types to be cleared at once.

BOOL success = [[RCIMClient sharedRCIMClient] clearConversations:@[@(ConversationType_PRIVATE),@(ConversationType_SYSTEM),@(ConversationType_GROUP)]];
ParameterTypeDescription
conversationTypeListNSArrayArray of conversation types, requires converting RCConversationType to NSNumber to build the Array

Delete All Conversations

The SDK does not have a built-in method to clear all conversations. If needed, you can achieve this in one of the following ways:

  • If the App does not involve ultra group business, you can use Delete Conversations by Type and pass all conversation types. This method will clear local messages.

  • First, retrieve the conversation list, then loop to delete specific conversations:

    NSArray *array = [[RCIMClient sharedRCIMClient] getConversationList:@[@(ConversationType_GROUP), @(ConversationType_PRIVATE)]];
    for (RCConversation *con in array) {
    [[RCIMClient sharedRCIMClient] removeConversation:con.conversationType targetId:con.targetId];
    }