Quick Reference for AI Agents & Developers
- Create group:
Group(guid:name:groupType:password:)→CometChat.createGroup(group:onSuccess:onError:) - Create with members:
CometChat.createGroupWithMembers(group:members:banMembers:onSuccess:onError:) - Group types:
.public,.private,.password - Required fields: GUID, name, groupType
- Optional: password (required for
.passwordtype), icon, description, metadata, tags - Related: Join Group · Retrieve Groups · Groups Overview
Group Class
TheGroup class represents a CometChat group with all its properties.
Group Initializers
- Swift
Group Properties
*
guid is specified at creation and cannot be edited laterSample Payload - Group Object
Sample Payload - Group Object
Group Object Properties:
Creator is automatically assigned
.admin scope with hasJoined = trueGUID Requirements
Create a Group
In other words, as a logged-in user, how do I create a public, private or password-protected group? You can create a group usingcreateGroup() method. This method takes a Group object as a parameter.
- Swift
- Objective C
Sample Payload - Create Public Group
Sample Payload - Create Public Group
Request Parameters:Error Response (CometChatException):
Success Response (Group Object):
Creator is automatically admin with
hasJoined = trueSample Payload - Create Private Group
Sample Payload - Create Private Group
Request Parameters:
Success Response (Group Object):
Private groups require invitation to join. Creator is automatically admin.
Sample Payload - Create Password Group
Sample Payload - Create Password Group
Request Parameters:
Success Response (Group Object):
Password is required for
.password type groups. Creator is automatically admin.Sample Payload - Create Group with Details
Sample Payload - Create Group with Details
Sample Payload - Create Group with Metadata
Sample Payload - Create Group with Metadata
Add Members While Creating a Group
You can create a group and add members at the same time using thecreateGroupWithMembers() method. This method takes the Group Object, Array of GroupMember Objects to be added & Array of UIDs to be banned.
GroupMember Class
- Swift
- Swift
Sample Payload - Create Group with Members
Sample Payload - Create Group with Members
Request Parameters:
Members to Add:
Success Response ([String: Any] Dictionary):
Response - Created Group:
Response - Added Members:
Error Response (CometChatException):