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 input.
To create an object of Group class, you can use either of the below two constructors:
new Group(String GUID, String name, String groupType, String password)new Group(String GUID, String name, String groupType, String password, String icon, String description)
groupType needs to be either of the below 3 values:
1.CometChatConstants.GROUP_TYPE_PUBLIC (public)
2.CometChatConstants.GROUP_TYPE_PASSWORD (password)
3.CometChatConstants.GROUP_TYPE_PRIVATE (private)
- Java
- Kotlin
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.
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 Group Member Object to be added & Array of UIDs to be banned.
To create an object of Group class, you can use either of the below two constructors:
new Group(String GUID, String name, String groupType, String password)new Group(String GUID, String name, String groupType, String password, String icon, String description)
groupType needs to be either of the below 3 values:
CometChat.GROUP_TYPE.PUBLICCometChat.GROUP_TYPE.PASSWORDCometChat.GROUP_TYPE.PRIVATE
Group Member class, you can use the below constructor:
new GroupMember(String UID, String scope)
- Java
- Kotlin
onSuccess() block of this method will provide you with 2 set of info:
- Group : The group object containing the information about the group that is created.
- HashMap<String, String> : A Hashmap that contains the key as the uid of the user that was supposed to be added and the value as success or error message.