Skip to main content

Retrieve the List of Group Members

In order to fetch the list of groups members for a group, you can use the GroupMembersRequest class. 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 GroupMembersRequestBuilder class allows you to set the below parameters: The GUID of the group for which the members are to be fetched must be specified in the constructor of the GroupMembersRequestBuilder class.

Set Limit

This method sets the limit i.e. the number of members that should be fetched in a single iteration.

Set Search Keyword

With offline support on, this filter is answered by the server only; the cached page is empty.
This method allows you to set the search string based on which the group members are to be fetched.

Set Scopes

This method allows you to fetch group members based on the specified scopes.

Set Status

With offline support on, this filter is answered by the server only; the cached page is empty.
This method allows you to fetch only the group members who are online or offline. Pass UsersRequest.USER_STATUS_ONLINE or UsersRequest.USER_STATUS_OFFLINE; leave it unset to fetch all members.
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.
Starting with v5.1.0, the CallbackListener overload of `fetchNext()` is deprecated. Use `GroupMemberFetchListener` instead; it requires SDK 5.1.0 or later, so on 5.0.x keep using CallbackListener. With offline support off, it behaves exactly like the old callback: onError is unchanged, and the server result arrives in the onServer… callback instead of onSuccess. With offline support on, it also delivers the cached result first; the old overload keeps working but receives only the server result. See Show Cached Data.

Offline Behaviour

With offline support enabled, GroupMembersRequest.fetchNext() on a GroupMemberFetchListener first delivers onCachedGroupMembers from the device (empty when nothing was recorded), then onServerGroupMembers with the live page to reconcile by uid. Offline, the read ends with onError with code ERROR_INTERNET_UNAVAILABLE after the cached page. A request that uses a server-only filter records nothing, so its cached page is always empty. See Show Cached Data.