SDKsiOS
Delete a conversation and its messages
Delete a specified conversation and all of its messages with OpenIM iOS SDK.
Invoke deleteConversationAndDeleteAllMsg:onSuccess:onFailure: to delete a specified conversation entry and clear all of its associated message records:
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
conversationID | NSString * | Yes | Target 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
- Local state removal: The client removes the conversation row matching
conversationIDfrom the local list and deletes corresponding chat records from local storage. - 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.
- 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.
Was this page helpful?