Skip to main content

Documentation Index

Fetch the complete documentation index at: https://cometchat-22654f5b-docs-android-v6-beta2.mintlify.app/llms.txt

Use this file to discover all available pages before exploring further.

// Fetch groups with filters
val groupsRequest = GroupsRequestBuilder()
    .setLimit(30)
    .joinedOnly(true)
    .setSearchKeyWord("search")
    .build()

groupsRequest.fetchNext(object : CallbackListener<List<Group>>() {
    override fun onSuccess(groups: List<Group>) { }
    override fun onError(e: CometChatException) { }
})

// Get specific group details
CometChat.getGroup("GUID", callback)

Retrieve List of Groups

Use GroupsRequestBuilder to configure filters, then call fetchNext() to retrieve groups.

Set Limit

Set the number of groups to fetch per request.
GroupsRequest groupsRequest = new GroupsRequest.GroupsRequestBuilder()
.setLimit(limit)
.build();

Set Search Keyword

Filter groups by a search string.
GroupsRequest groupsRequest = new GroupsRequest.GroupsRequestBuilder()
.setSearchKeyWord("abc")
.build();

Joined Only

Return only groups the logged-in user has joined.
GroupsRequest groupsRequest = new GroupsRequest.GroupsRequestBuilder()
.joinedOnly(true)
.build();

Set Tags

Filter groups by tags. Only groups tagged with the specified tags are returned.
List<String> tags = new ArrayList<>();
tags.add("tag1");
tags.add("tag2");
GroupsRequest groupsRequest = new GroupsRequest.GroupsRequestBuilder()
.setLimit(limit)
.setTags(tags)
.build();  

With Tags

Include tag data in the response when set to true.
GroupsRequest groupsRequest = new GroupsRequest.GroupsRequestBuilder()
.setLimit(limit)
.withTags(true)
.build();

Fetch Groups

After configuring the builder, call build() then fetchNext() to retrieve groups. Public and password-protected groups are always included. Private groups only appear if the user is a member.
private GroupsRequest groupsRequest = null;
private int limit = 30;

groupsRequest = new GroupsRequest.GroupsRequestBuilder().setLimit(limit).build();

groupsRequest.fetchNext(new CometChat.CallbackListener<List<Group>>() {
@Override
public void onSuccess(List <Group> list) {
  Log.d(TAG, "Groups list fetched successfully: " + list.size());
}
@Override
public void onError(CometChatException e) {
  Log.d(TAG, "Groups list fetching failed with exception: " + e.getMessage());
}
});

Retrieve Particular Group Details

Use getGroup() to fetch details for a specific group by GUID.
private String GUID = "GUID";

CometChat.getGroup(GUID, new CometChat.CallbackListener<Group>() {
@Override
public void onSuccess(Group group) {
  Log.d(TAG, "Group details fetched successfully: " + group.toString());        
}

@Override
public void onError(CometChatException e) { 
  Log.d(TAG, "Group details fetching failed with exception: " + e.getMessage());   

}
});
ParameterDescription
GUIDThe GUID of the group for whom the details are to be fetched
On success, the Group object containing the details of the group is returned.

Get Online Group Member Count

Use getOnlineGroupMemberCount() to get the count of online members for specific groups.
List<String> guids = new ArrayList<>();
guids.add("cometchat-guid-1");
guids.add("cometchat-guid-11");

CometChat.getOnlineGroupMemberCount(guids, new CometChat.CallbackListener<HashMap<String, Integer>>() {
@Override
public void onSuccess(HashMap<String, Integer> stringIntegerHashMap) {
  Log.d(TAG, "Online count fetched successfully " + stringIntegerHashMap.toString());
}

@Override
public void onError(CometChatException e) {
  Log.d(TAG, e.getMessage());
}
});
This method returns a Hashmap with the GUID of the group as the key and the online member count for that group as the value.

Group Payload Structure

The Group object returned by SDK methods contains the following fields:
ParameterTypeDescription
guidStringUnique identifier of the group
nameStringDisplay name of the group
typeStringGroup type. Values: "public", "private", "password"
passwordStringPassword for protected groups (null for public/private groups)
iconStringURL to group icon image
descriptionStringDescription of the group
ownerStringUID of the group owner
metadataJSONObjectCustom data set by developer. Can contain any key-value pairs
createdAtlongUnix timestamp when group was created
updatedAtlongUnix timestamp of last group update
hasJoinedbooleanWhether the logged-in user has joined this group
joinedAtlongUnix timestamp when logged-in user joined the group
scopeStringLogged-in user’s scope in group. Values: "admin", "moderator", "participant"
membersCountintTotal number of members in the group
tagsArray<String>List of tags for group identification and filtering
isBannedFromGroupbooleanWhether the logged-in user is banned from this group
Sample Group Object:
{
  "guid": "group_123",
  "name": "Developers",
  "type": "public",
  "password": null,
  "icon": "https://example.com/icon.png",
  "description": "A group for developers",
  "owner": "user_123",
  "metadata": {
    "category": "tech",
    "isVerified": true
  },
  "createdAt": 1699800000,
  "updatedAt": 1699900000,
  "hasJoined": true,
  "joinedAt": 1699850000,
  "scope": "admin",
  "membersCount": 25,
  "tags": ["official", "support"],
  "isBannedFromGroup": false
}

Next Steps

Create Group

Create new groups for your users

Join Group

Join groups to participate in conversations

Retrieve Members

Fetch list of group members

Additional Filtering

Learn more about advanced filtering options