Skip to main content
Quick Reference for AI Agents & Developers
To delete a group you need to use the deleteGroup() method. The user must be an Admin of the group they are trying to delete.
let GUID = "GUID";

CometChat.deleteGroup(GUID: GUID, onSuccess: { (response) in

  print("Group deleted successfully.")

}) { (error) in

  print("Group delete failed with error: " + error!.errorDescription);
}
The deleteGroup() method takes the following parameters:
ParameterDescription
GUIDThe GUID of the group you would like to delete
Method Signature:
ParameterTypeDescription
GUIDStringUnique group identifier to delete. Example: "cometchat-guid-1"
onSuccess(String) -> VoidSuccess callback with response message
onError(CometChatException?) -> VoidError callback with exception details
Request Parameters:
ParameterTypeDescription
GUIDStringThe unique identifier of the group to delete. Example: "cometchat-guid-1"
Prerequisites:
RequirementDescription
User logged inUser must be authenticated via CometChat.login()
Admin permissionUser must be the admin/owner of the group
Valid GUIDGroup with specified GUID must exist
Success Callback Parameter:
ParameterTypeDescription
responseStringSuccess confirmation message. Example: "Group deleted successfully."
Post-Deletion Effects:
EffectDescription
Group removedGroup is permanently deleted from the system
Members removedAll members lose access to the group
Messages deletedAll group messages are permanently deleted
Conversations clearedGroup conversations removed from all members’ conversation lists
Cannot recoverThis action is irreversible
Real-time Event Triggered:
EventDelegate MethodDescription
onGroupDeletedCometChatGroupDelegateNotifies all group members that the group has been deleted
onGroupDeleted Event Payload:
ParameterTypeDescription
groupGroupThe deleted group object. See Group Object below
Group Object (in event):
ParameterTypeDescription
guidStringGroup’s unique ID. Example: "cometchat-guid-1"
nameStringGroup’s display name. Example: "Development Team"
iconString?Group’s icon URL. Example: "https://example.com/group.png"
descriptionString?Group description. Example: "Team discussions"
groupTypeGroupTypeGroup type. Example: .public
ownerStringGroup owner UID. Example: "cometchat-uid-1"
membersCountIntNumber of members at deletion. Example: 15
createdAtIntCreation timestamp. Example: 1699700000
Error Callback Parameter:
ParameterTypeDescription
errorCometChatException?Error object containing failure details
CometChatException Object:
ParameterTypeDescription
errorCodeStringMachine-readable error code. Example: "ERR_GROUP_NOT_JOINED"
errorDescriptionStringHuman-readable error message
errorDetails[String: Any]?Additional error context
Common Error Codes:
Error CodeDescription
ERR_NOT_LOGGED_INUser is not logged in. Call CometChat.login() first
ERR_GUID_NOT_FOUNDGroup with specified GUID does not exist
ERR_GROUP_NOT_FOUNDGroup does not exist in the system
ERR_GROUP_NOT_JOINEDUser is not a member of the group
ERR_PERMISSION_DENIEDUser is not admin/owner of the group
ERR_INVALID_GUIDGUID format is invalid or empty
Error Response Example (Not a Member):
ParameterTypeDescription
errorCodeStringExample: "ERR_GROUP_NOT_JOINED"
errorDescriptionStringExample: "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."
Error Response Example (Permission Denied):
ParameterTypeDescription
errorCodeStringExample: "ERR_PERMISSION_DENIED"
errorDescriptionStringExample: "Only the admin can delete this group."
Error Response Example (Group Not Found):
ParameterTypeDescription
errorCodeStringExample: "ERR_GUID_NOT_FOUND"
errorDescriptionStringExample: "Group with the specified GUID does not exist."
Important Considerations:
  • Only the group admin/owner can delete the group
  • This action is PERMANENT and cannot be undone
  • All group data including messages will be permanently lost
  • All members will receive the onGroupDeleted event via CometChatGroupDelegate