Skip to main content
Quick Reference for AI Agents & Developers
  • Update group: CometChat.updateGroup(group:onSuccess:onError:)
  • Updatable fields: name, description, icon, metadata, tags
  • Permission: Only group owner or admin can update
  • Related: Create Group · Delete Group · Groups Overview

Update Group

In other words, as a group owner, how can I update the group details? You can update the existing details of the group using the updateGroup() method.
let GUID = "GUID";
let groupName = "Hello Group!";
let groupType: CometChat.groupType = .public;

let groupTobeUpdated = Group(guid: GUID, name: groupName, groupType: groupType, password: nil)

CometChat.updateGroup(group: groupTobeUpdated, onSuccess: { (group) in

  print("Groups details updated successfully. " + group.stringValue())

}) { (error) in

   print("Group details update failed with error: " + error!.errorDescription);
}
This method takes an instance of the Group class as a parameter that should contain the data that you wish to update.
ParameterDescription
groupan instance of class Group
After a successful update of the group, you will receive an instance of the Group class containing update information of the group.
Method Signature:
ParameterTypeDescription
groupGroupGroup object with updated properties
onSuccess(Group) -> VoidSuccess callback with updated Group object
onError(CometChatException?) -> VoidError callback with exception details
Group Object (Input):
ParameterTypeDescription
guidStringUnique group identifier (required). Example: "cometchat-guid-1"
nameStringUpdated group name. Example: "Updated Test Group"
groupTypeGroupTypeGroup type (required). Example: .public
iconString?Updated group icon URL. Example: "https://example.com/new-icon.png"
descriptionString?Updated group description. Example: "Updated description"
metadata[String: Any]?Updated custom metadata. Example: ["key": "value"]
tags[String]?Updated group tags. Example: ["updated", "team"]
passwordString?Password (required for password-protected groups). Example: nil
Updatable Properties:
PropertyTypeDescription
nameStringGroup display name
iconString?Group icon URL
descriptionString?Group description text
metadata[String: Any]?Custom key-value metadata
tags[String]Array of searchable tags
Non-Updatable Properties:
PropertyDescription
guidCannot be changed after creation
groupTypeCannot be changed after creation
ownerUse Transfer Ownership instead
membersCountAutomatically managed by system
createdAtSet at creation time
Prerequisites:
RequirementDescription
User logged inUser must be authenticated via CometChat.login()
Owner/Admin permissionUser must be the owner or admin of the group
Valid GUIDGroup with specified GUID must exist
Valid nameGroup name cannot be empty
Success Callback Parameter:
ParameterTypeDescription
groupGroupUpdated Group object. See Group Object below
Updated Group Object:
ParameterTypeDescription
guidStringGroup’s unique ID. Example: "cometchat-guid-1"
nameStringUpdated group name. Example: "Updated Test Group"
groupTypeGroupTypeGroup type. Example: .public
iconString?Updated icon URL. Example: "https://example.com/new-icon.png"
descriptionString?Updated description. Example: "Updated description"
ownerStringGroup owner UID. Example: "cometchat-uid-1"
membersCountIntNumber of members. Example: 15
createdAtIntCreation timestamp. Example: 1699700000
updatedAtIntUpdate timestamp. Example: 1699800000
hasJoinedBoolWhether current user has joined. Example: true
joinedAtIntJoin timestamp. Example: 1699710000
scopeMemberScopeCurrent user’s scope. Example: .admin
metadata[String: Any]?Updated custom metadata
tags[String]Updated group tags
GroupType Enum Values:
ValueDescription
.publicAnyone can join without approval
.privateRequires invitation to join
.passwordRequires password to join
MemberScope Enum Values:
ValueDescription
.adminAdministrator privileges (can update group)
.moderatorModerator privileges
.participantRegular member (cannot update group)
Real-time Event Triggered:
EventDelegate MethodDescription
onGroupUpdatedCometChatGroupDelegateNotifies all group members of the update
Error Callback Parameter:
ParameterTypeDescription
errorCometChatException?Error object containing failure details
CometChatException Object:
ParameterTypeDescription
errorCodeStringMachine-readable error code. Example: "ERR_NOT_A_MEMBER"
errorDescriptionStringHuman-readable error message
errorDetails[String: Any]?Additional error context
Common Error Codes:
Error CodeDescriptionResolution
ERR_NOT_LOGGED_INUser is not logged inLogin first using CometChat.login()
ERR_GUID_NOT_FOUNDGroup does not existVerify the GUID is correct
ERR_GROUP_NOT_FOUNDGroup does not existVerify the GUID is correct
ERR_NOT_A_MEMBERUser is not a member of the groupJoin the group first
ERR_PERMISSION_DENIEDNo permission to updateOnly owner or admin can update
ERR_EMPTY_GROUP_NAMEGroup name is emptyProvide a valid group name
ERR_INVALID_GUIDGUID format is invalidProvide a valid GUID string
Error Response Example (Not a Member):
ParameterTypeDescription
errorCodeStringExample: "ERR_NOT_A_MEMBER"
errorDescriptionStringExample: "The user with UID cometchat-uid-2 is not a member of group with GUID Cometchat-guid-1."
Error Response Example (Permission Denied):
ParameterTypeDescription
errorCodeStringExample: "ERR_PERMISSION_DENIED"
errorDescriptionStringExample: "Only the owner or admin can update this group."
Error Response Example (Group Not Found):
ParameterTypeDescription
errorCodeStringExample: "ERR_GUID_NOT_FOUND"
errorDescriptionStringExample: "Group with the specified GUID does not exist."
Method Signature:
ParameterTypeDescription
GUIDStringGroup identifier to fetch. Example: "cometchat-guid-1"
onSuccess(Group) -> VoidSuccess callback with Group object
onError(CometChatException?) -> VoidError callback with exception details
Request Parameters:
ParameterTypeDescription
guidStringThe unique identifier of the group to fetch. Example: "Cometchat-guid-1"
Use Case:
StepActionDescription
1Fetch groupCall CometChat.getGroup(GUID:) to get current group details
2Modify propertiesUpdate desired properties on the returned Group object
3Update groupCall CometChat.updateGroup(group:) with modified object
Error Callback Parameter:
ParameterTypeDescription
errorCometChatException?Error object containing failure details
Error Response Example:
ParameterTypeDescription
errorCodeStringExample: "ERR_NOT_A_MEMBER"
errorDescriptionStringExample: "The user with UID cometchat-uid-2 is not a member of group with GUID Cometchat-guid-1."
Common getGroup() Error Codes:
Error CodeDescription
ERR_NOT_LOGGED_INUser is not logged in
ERR_GUID_NOT_FOUNDGroup does not exist
ERR_NOT_A_MEMBERUser is not a member of the group
ERR_INVALID_GUIDGUID format is invalid

Real-time Events

When a group is updated, all members receive the onGroupUpdated event via CometChatGroupDelegate:
extension YourClass: CometChatGroupDelegate {
    func onGroupUpdated(action: ActionMessage, updatedGroup: Group, updatedBy: User) {
        print("Group updated: \(updatedGroup.name ?? "")")
        print("Updated by: \(updatedBy.name ?? "")")
    }
}
Delegate Method Parameters:
ParameterTypeDescription
actionActionMessageAction message describing the update
updatedGroupGroupThe updated Group object
updatedByUserUser who performed the update
ActionMessage Object:
ParameterTypeDescription
idIntMessage ID. Example: 12345
messageCategoryMessageCategoryCategory. Example: .action
actionStringAction type. Example: "groupUpdated"
actionByUserUser who performed action
actionOnGroupGroup that was updated
sentAtIntTimestamp. Example: 1699800000
updatedBy User Object:
ParameterTypeDescription
uidStringUser’s unique ID. Example: "cometchat-uid-1"
nameStringUser’s display name. Example: "John Doe"
avatarString?User’s avatar URL
statusUserStatusOnline status. Example: .online