Skip to main content

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 using createGroup() method. This method takes a Group object as input. The groupType needs to be either of the below 3 values: 1.CometChatGroupType.public (public) 2.CometChatGroupType.password (password) 3.CometChatGroupType.private (private)
The createGroup() method takes the following parameters: After the successful creation of the group, you will receive an instance of Group class which contains all the information about the particular group.
GUID can be alphanumeric with underscore and hyphen. Spaces, punctuation and other special characters are not allowed.

Create a Group with Members

In other words, how do I create a group and add members in a single step? You can create a group and add members simultaneously using the createGroupWithMembers() method. This is more efficient than creating a group first and then adding members separately.
The createGroupWithMembers() method takes the following parameters: The onSuccess callback returns:
  • group: The created Group object
  • failedMembers: A map containing UIDs of members that failed to be added along with the error reason
The GroupMember class takes the following parameters:

Group Class