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.

// Retrieve group members with pagination
GroupMembersRequest request = (GroupMembersRequestBuilder("GROUP_ID")
  ..limit = 30
).build();

await request.fetchNext(
  onSuccess: (List<GroupMember> members) {
    for (GroupMember member in members) {
      debugPrint("Member: ${member.name}, Scope: ${member.scope}");
    }
  },
  onError: (CometChatException e) => debugPrint("Error: ${e.message}"),
);

// Filter by scope (admin, moderator, participant)
GroupMembersRequest scopedRequest = (GroupMembersRequestBuilder("GROUP_ID")
  ..limit = 30
  ..scopes = ["admin", "moderator"]
).build();

// Search members
GroupMembersRequest searchRequest = (GroupMembersRequestBuilder("GROUP_ID")
  ..limit = 30
  ..searchKeyword = "john"
).build();
Fetch the members of a group with filtering by scope, online status, and search keyword. Results are returned as GroupMember objects, which extend User with group-specific fields like scope.

Retrieve the List of Group Members

In order to fetch the list of groups members for a group, you can use the GroupMembersRequest class.
Available via: SDK | REST API | UI Kits
To use this class i.e to create an object of the GroupMembersRequest class, you need to use the GroupMembersRequestBuilder class. The GroupMembersRequestBuilder class allows you to set the parameters based on which the groups are to be fetched. The GUID of the group for which the members are to be fetched must be specified in the constructor of the GroupMembersRequestBuilder class.

GroupMembersRequestBuilder

ParameterTypeDescription
guidString(Required, constructor) Group ID for the group whose members are to be fetched.
limitint?Maximum number of members to fetch per request. Max 100, default 30.
searchKeywordString?Search string to filter members by name.
scopesList<String>?Filter members by scope ("admin", "moderator", "participant").
statusString?Filter members by online status ("online", "offline"). If not set, returns all members.
setPageint?Fetch group members from a particular page number.

Set Limit

This method sets the limit i.e. the number of members that should be fetched in a single iteration.
String GUID = "GUID";
  GroupMembersRequest  groupMembersRequest = (GroupMembersRequestBuilder(GUID)
  ..limit = 20
  ).build();

Set Search Keyword

This method allows you to set the search string based on which the group members are to be fetched.
String GUID = "GUID";
GroupMembersRequest  groupMembersRequest = (GroupMembersRequestBuilder(GUID)
  ..limit = 20
  ..searchKeyword = "abc"
  ).build();

Set Scopes

This method allows you to fetch group members based on the specified scopes.
List<String> scopes =[];
scopes.add("admin");
scopes.add("moderator");
String GUID = "GUID";
GroupMembersRequest  groupMembersRequest = (GroupMembersRequestBuilder(GUID)
  ..limit = 20
  ..scopes = scopes
  ).build();
Relevant fields to access on returned members:
FieldPropertyReturn TypeDescription
scopescopeStringScope of the member in the group ("admin", "moderator", or "participant")

Set Status

Filters members by online status:
ValueDescription
"online"Only online members
"offline"Only offline members
If not set, returns all members regardless of status.
String GUID = "GUID";
GroupMembersRequest groupMembersRequest = (GroupMembersRequestBuilder(GUID)
  ..limit = 20
  ..status = "online"
).build();
Finally, once all the parameters are set to the builder class, you need to call the build() method to get the object of the GroupMembersRequest class. Once you have the object of the GroupMembersRequest class, you need to call the fetchNext() method. Calling this method will return a list of GroupMember objects containing N number of members depending on the limit set.
String GUID = "GUID";
GroupMembersRequest  groupMembersRequest = (GroupMembersRequestBuilder(GUID)
  ..limit = 20
  ).build();

groupMembersRequest.fetchNext(onSuccess: (List<GroupMember> groupMemberList){
    debugPrint("Group Members fetched Successfully : $groupMemberList ");  
  }, onError: (CometChatException e) {
    debugPrint("Delete Group failed with exception: ${e.message}");
  });
The fetchNext() method returns a list of GroupMember objects. GroupMember extends User and adds group-specific fields.
On Success — A List<GroupMember> containing the group members for the specified group (each item is a GroupMember object):GroupMember Object (per item in array):
ParameterTypeDescriptionSample Value
uidstringUnique identifier of the user"cometchat-uid-1"
namestringDisplay name of the user"Andrew Joseph"
linkstringProfile linknull
avatarstringAvatar URL"https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-1.webp"
metadataobjectCustom metadata{}
statusstringOnline status"online"
rolestringUser role"default"
statusMessagestringStatus messagenull
tagsarrayUser tags[]
hasBlockedMebooleanWhether this user has blocked the current userfalse
blockedByMebooleanWhether the current user has blocked this userfalse
lastActiveAtnumberEpoch timestamp of last activity1745554700
scopestringMember scope in the group"admin"
joinedAtnumberEpoch timestamp when the member joined the group1745550000
ParameterTypeDescriptionSample Value
codestringError code identifier"ERR_GUID_NOT_FOUND"
messagestringHuman-readable error message"The specified group does not exist."
detailsstringAdditional technical details"Please verify the group ID and try again."

Next Steps

Add Members

Add new members to your groups

Kick/Ban Members

Remove or ban members from groups