Quick Reference for AI Agents & Developers// Delete a user conversation
await CometChat.deleteConversation(
"UID",
CometChatConversationType.user,
onSuccess: (String message) => debugPrint("Deleted: $message"),
onError: (CometChatException e) => debugPrint("Error: ${e.message}"),
);
// Delete a group conversation
await CometChat.deleteConversation(
"GUID",
CometChatConversationType.group,
onSuccess: (String message) => debugPrint("Deleted: $message"),
onError: (CometChatException e) => debugPrint("Error: ${e.message}"),
);
In case you want to delete a conversation, you can use the deleteConversation() method.
This method takes two parameters. The unique id (UID/GUID) of the conversation to be deleted & the type (user/group) of conversation to be deleted.
This operation is irreversible. Deleted conversations cannot be recovered. All messages in the conversation will be removed from the user’s view.
String conversationWith = "UID";
String conversationType = CometChatConversationType.user;
await CometChat.deleteConversation(conversationWith, conversationType,
onSuccess: (String str){
debugPrint("Conversation deleted successfully at : $str");
},
onError: (CometChatException e){
debugPrint("Conversation deletion failed : ${e.message}");
}
);
String conversationWith = "GUID";
String conversationType = CometChatConversationType.group;
await CometChat.deleteConversation(conversationWith, conversationType,
onSuccess: (String str){
debugPrint("Conversation deleted successfully at : $str");
},
onError: (CometChatException e){
debugPrint("Conversation deletion failed : ${e.message}");
}
);
This method deletes the conversation only for the logged-in user. To delete a conversation for all the users of the conversation, please refer to our REST API documentation here.
The deleteConversation() method takes the following parameters:
| Parameter | Description | Required |
|---|
| conversationWith | UID of the user or GUID of the group whose conversation you want to delete. | YES |
| conversationType | The type of conversation you want to delete . It can be either user or group. | YES |
Next Steps