Browse SDKs · iOS
Platform
SDKsiOS

Delete a conversation and its messages

Delete a specified conversation and all of its messages with OpenIM iOS SDK.

Copy

Invoke deleteConversationAndDeleteAllMsg:onSuccess:onFailure: to delete a specified conversation entry and clear all of its associated message records:

Parameters

ParameterTypeRequiredDescription
conversationIDNSString *YesTarget conversation ID to delete.

Code example

[[OIMManager manager] deleteConversationAndDeleteAllMsg:@"c2c_user1002"
                                               onSuccess:^(NSString * _Nullable data) {
                                                   NSLog(@"deleteConversationAndDeleteAllMsg success");
                                               }
                                               onFailure:^(NSInteger code, NSString *message) {
                                                   NSLog(@"deleteConversationAndDeleteAllMsg failed: %ld %@", (long)code, message);
                                               }];

Return value

The onSuccess callback returns confirmation when the operation succeeds.

State changes after the call

  1. Local state removal: The client removes the conversation row matching conversationID from the local list and deletes corresponding chat records from local storage.
  2. Relationship scope: This operation only deletes local conversation and message data for the current account. It does not terminate friend relationships, nor does it leave or disband groups. When new messages arrive for this target, the conversation is recreated automatically and returns to the list.
  3. Re-query calibration: If you only need to temporarily remove the conversation entry while keeping chat history intact, refer to Hide a conversation. For conversation listener setup, refer to Retrieve conversation list.