Quick Reference for AI Agents & Developers
- Delete conversation:
CometChat.deleteConversation(conversationWith:conversationType:onSuccess:onError:) - Conversation types:
.user,.group - Related: Retrieve Conversations · Messaging Overview
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.
Delete User Conversation
- Swift
Sample Payloads - Delete User Conversation
Sample Payloads - Delete User Conversation
- Request
- Success Response
- Error Response
Method:
CometChat.deleteConversation(conversationWith:conversationType:)| Parameter | Type | Value |
|---|---|---|
| conversationWith | String | "cometchat-uid-1" |
| conversationType | CometChat.ConversationType | .user |
Delete Group Conversation
- Swift
Sample Payloads - Delete Group Conversation
Sample Payloads - Delete Group Conversation
- Request
- Success Response
- Error Response
Method:
CometChat.deleteConversation(conversationWith:conversationType:)| Parameter | Type | Value |
|---|---|---|
| conversationWith | String | "group-guid-1" |
| conversationType | CometChat.ConversationType | .group |
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.
Method Parameters
ThedeleteConversation() method takes the following parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
| conversationWith | String | YES | UID of user or GUID of group |
| conversationType | CometChat.ConversationType | YES | .user or .group |
| onSuccess | (String) -> Void | YES | Success callback |
| onError | (CometChatException?) -> Void | YES | Error callback |
Success & Failure Responses
Delete Conversation Success Response
When a conversation is successfully deleted, theonSuccess callback returns a success message:
- Swift
Delete Conversation Failure Response
When deletion fails, theonError callback returns a CometChatException:
- Swift
After Deletion
| Effect | Description |
|---|---|
| Conversation removed | For logged-in user only |
| Messages deleted | For logged-in user only |
| Other participants | Still have access |
Common Error Codes
| Error Code | Description | Resolution |
|---|---|---|
ERR_CONVERSATION_NOT_FOUND | Conversation doesn’t exist | Verify conversation exists |
ERR_UID_NOT_FOUND | User UID doesn’t exist | Verify user UID |
ERR_GROUP_NOT_FOUND | Group GUID doesn’t exist | Verify group GUID |
ERR_NOT_LOGGED_IN | User is not logged in | Login first |