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, the 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 delete messages in conversation interface simultaneously.
Method
Future<int> removeConversation(RCIMIWConversationType type, String targetId, String? channelId, {IRCIMIWRemoveConversationCallback? callback});
Parameter Description
Parameter | Type | Description |
---|---|---|
type | RCIMIWConversationType | Conversation type |
targetId | String | Conversation ID |
channelId | String | Channel ID, only supported for ultra groups, pass null for other conversation types |
callback | IRCIMIWRemoveConversationCallback | Callback for the conversation removal event. SDK supports callback from version 5.3.1. Other callback methods are deprecated from version 5.4.0. If the callback parameter is provided, only the callback will be triggered. |
Return Value
Return Value | Description |
---|---|
Future<int> | Status code of the current operation. 0 indicates success. Specific results need to be implemented via interface callback. Non-zero indicates failure, and no callback will be triggered. Refer to the error codes for detailed errors. |
Code Example
IRCIMIWRemoveConversationCallback? callback = IRCIMIWRemoveConversationCallback(onConversationRemoved: (int? code) {
//...
});
int? ret = await engine?.removeConversation(type, targetId, channelId, callback:callback);
Callback Method
- onConversationRemoved
Function(int? code, RCIMIWConversationType? type, String? targetId, String? channelId)? onConversationRemoved;
Parameter Description
Parameter | Type | Description |
---|---|---|
code | int | Status code of the callback. 0 indicates success, non-zero indicates an exception. |
type | RCIMIWConversationType | Conversation type |
targetId | String | Conversation ID |
channelId | String | Channel ID, only supported for ultra groups, pass null for other conversation types. |
Code Example
engine?.onConversationRemoved = (int? code, RCIMIWConversationType? type, String? targetId, String? channelId) {
//...
};
Delete Conversations by Type
Deletes conversations by specified conversation types and deletes the messages within the conversations.
Method
Future<int> removeConversations(List<RCIMIWConversationType> conversationTypes, String? channelId, {IRCIMIWRemoveConversationsCallback? callback});
Parameter Description
Parameter | Type | Description |
---|---|---|
conversationTypes | List<RCIMIWConversationType> | Collection of conversation types |
channelId | String | Channel ID, only supported for ultra groups, pass null for other conversation types. |
callback | IRCIMIWRemoveConversationsCallback | Callback for the conversation list removal event. SDK supports callback from version 5.3.1. Other callback methods are deprecated from version 5.4.0. If the callback parameter is provided, only the callback will be triggered. |
Return Value
Return Value | Description |
---|---|
Future<int> | Status code of the current operation. 0 indicates success. Specific results need to be implemented via interface callback. Non-zero indicates failure, and no callback will be triggered. Refer to the error codes for detailed errors. |
Code Example
IRCIMIWRemoveConversationsCallback? callback = IRCIMIWRemoveConversationsCallback(onConversationsRemoved: (int? code) {
//...
});
int? ret = await engine?.removeConversations(conversationTypesInt, channelId, callback:callback);
Callback Method
- onConversationsRemoved
Function(int? code, List<RCIMIWConversationType>? conversationTypes, String? channelId)? onConversationsRemoved;
Parameter Description
Parameter | Type | Description |
---|---|---|
code | int | Status code of the callback. 0 indicates success, non-zero indicates an exception. |
conversationTypes | List<RCIMIWConversationType> | Collection of conversation types |
channelId | String | Channel ID, only supported for ultra groups, pass null for other conversation types. |
Code Example
engine?.onConversationsRemoved = (int? code, List<RCIMIWConversationType>? conversationTypes, String? channelId) {
//...
};
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 all conversation types.
This method will delete both the conversations and the messages. It is recommended to display chatrooms and ultra groups separately in the UI, so they can be excluded during deletion.
Code Example
engine.removeConversations(
[RCIMIWConversationType.private, RCIMIWConversationType.group, RCIMIWConversationType.system],
null,
);