Quick Reference for AI Agents & Developers
- Delete group:
CometChat.deleteGroup(GUID:onSuccess:onError:) - Permission: Only group admin can delete
- Related: Create Group · Leave Group · Groups Overview
deleteGroup() method. The user must be an Admin of the group they are trying to delete.
- Swift
- Objective C
deleteGroup() method takes the following parameters:
| Parameter | Description |
|---|---|
| GUID | The GUID of the group you would like to delete |
Sample Payload - deleteGroup() Request
Sample Payload - deleteGroup() Request
Method Signature:
Request Parameters:
Prerequisites:
| Parameter | Type | Description |
|---|---|---|
| GUID | String | Unique group identifier to delete. Example: "cometchat-guid-1" |
| onSuccess | (String) -> Void | Success callback with response message |
| onError | (CometChatException?) -> Void | Error callback with exception details |
| Parameter | Type | Description |
|---|---|---|
| GUID | String | The unique identifier of the group to delete. Example: "cometchat-guid-1" |
| Requirement | Description |
|---|---|
| User logged in | User must be authenticated via CometChat.login() |
| Admin permission | User must be the admin/owner of the group |
| Valid GUID | Group with specified GUID must exist |
Sample Payload - deleteGroup() Success Response
Sample Payload - deleteGroup() Success Response
Success Callback Parameter:
Post-Deletion Effects:
Real-time Event Triggered:
onGroupDeleted Event Payload:
Group Object (in event):
| Parameter | Type | Description |
|---|---|---|
| response | String | Success confirmation message. Example: "Group deleted successfully." |
| Effect | Description |
|---|---|
| Group removed | Group is permanently deleted from the system |
| Members removed | All members lose access to the group |
| Messages deleted | All group messages are permanently deleted |
| Conversations cleared | Group conversations removed from all members’ conversation lists |
| Cannot recover | This action is irreversible |
| Event | Delegate Method | Description |
|---|---|---|
| onGroupDeleted | CometChatGroupDelegate | Notifies all group members that the group has been deleted |
| Parameter | Type | Description |
|---|---|---|
| group | Group | The deleted group object. See Group Object below |
| Parameter | Type | Description |
|---|---|---|
| guid | String | Group’s unique ID. Example: "cometchat-guid-1" |
| name | String | Group’s display name. Example: "Development Team" |
| icon | String? | Group’s icon URL. Example: "https://example.com/group.png" |
| description | String? | Group description. Example: "Team discussions" |
| groupType | GroupType | Group type. Example: .public |
| owner | String | Group owner UID. Example: "cometchat-uid-1" |
| membersCount | Int | Number of members at deletion. Example: 15 |
| createdAt | Int | Creation timestamp. Example: 1699700000 |
Sample Payload - deleteGroup() Error Response
Sample Payload - deleteGroup() Error Response
Error Callback Parameter:
CometChatException Object:
Common Error Codes:
Error Response Example (Not a Member):
Error Response Example (Permission Denied):
Error Response Example (Group Not Found):
| Parameter | Type | Description |
|---|---|---|
| error | CometChatException? | Error object containing failure details |
| Parameter | Type | Description |
|---|---|---|
| errorCode | String | Machine-readable error code. Example: "ERR_GROUP_NOT_JOINED" |
| errorDescription | String | Human-readable error message |
| errorDetails | [String: Any]? | Additional error context |
| Error Code | Description |
|---|---|
| ERR_NOT_LOGGED_IN | User is not logged in. Call CometChat.login() first |
| ERR_GUID_NOT_FOUND | Group with specified GUID does not exist |
| ERR_GROUP_NOT_FOUND | Group does not exist in the system |
| ERR_GROUP_NOT_JOINED | User is not a member of the group |
| ERR_PERMISSION_DENIED | User is not admin/owner of the group |
| ERR_INVALID_GUID | GUID format is invalid or empty |
| Parameter | Type | Description |
|---|---|---|
| errorCode | String | Example: "ERR_GROUP_NOT_JOINED" |
| errorDescription | String | Example: "The user with UID cometchat-uid-2 is not a member of the group with GUID cometchat-guid-1. Please join the group to access it." |
| Parameter | Type | Description |
|---|---|---|
| errorCode | String | Example: "ERR_PERMISSION_DENIED" |
| errorDescription | String | Example: "Only the admin can delete this group." |
| Parameter | Type | Description |
|---|---|---|
| errorCode | String | Example: "ERR_GUID_NOT_FOUND" |
| errorDescription | String | Example: "Group with the specified GUID does not exist." |