Retrieving group channels
The channel retrieval APIs for group channels work the same as for direct channels. See Retrieving Channels for the full API reference using BaseChannel and BaseChannel.createChannelsQuery().
For group-specific queries (group profiles, member lists), see the sections below.
Get group profiles
Use GroupChannel.getGroupsInfo() to retrieve group profile information.
- The SDK checks locally first. If the user is not in the group, or the cached data is older than 10 minutes, it fetches from the server.
- Maximum 20 groups per call.
- Kotlin
- Java
kotlin
val groupIds = listOf("groupId1", "groupId2", "groupId3")
GroupChannel.getGroupsInfo(groupIds) { groups, error ->
if (error == null && groups != null) {
groups.forEach { group ->
println("Group: ${group.groupId}, Name: ${group.groupName}")
}
}
}
Java
List<String> groupIds = Arrays.asList("groupId1", "groupId2", "groupId3");
GroupChannel.getGroupsInfo(groupIds, (groups, error) -> {
if (error == null && groups != null) {
for (GroupInfo group : groups) {
System.out.println("Group: " + group.getGroupId());
}
}
});
Get joined group profiles
Use GroupChannel.getJoinedGroups() to retrieve profiles for groups the current user has joined. Supports batch queries of up to 20 group IDs.
- Kotlin
- Java
kotlin
val groupIds = listOf("groupId1", "groupId2")
GroupChannel.getJoinedGroups(groupIds) { groups, error ->
if (error == null && groups != null) {
groups.forEach { group ->
println("Joined group: ${group.groupId}")
}
}
}
Java
List<String> groupIds = Arrays.asList("groupId1", "groupId2");
GroupChannel.getJoinedGroups(groupIds, (groups, error) -> {
if (error == null && groups != null) {
for (GroupInfo group : groups) {
System.out.println("Joined group: " + group.getGroupId());
}
}
});
Get joined groups by role (paginated)
Use GroupChannel.createJoinedGroupsByRoleQuery() with JoinedGroupsByRoleQueryParams to retrieve joined groups filtered by member role, with pagination.
GroupMemberRole enum values:
| Enum Value | Role |
|---|---|
GroupMemberRole.UNDEF | All roles |
GroupMemberRole.NORMAL | Channel member |
GroupMemberRole.MANAGER | Channel admin |
GroupMemberRole.OWNER | Channel owner |
- Kotlin
- Java
kotlin
val params = JoinedGroupsByRoleQueryParams().apply {
role = GroupMemberRole.UNDEF
pageSize = 20
}
val query = GroupChannel.createJoinedGroupsByRoleQuery(params)
query.loadNextPage { result, error ->
if (error == null && result != null) {
val groups = result.data
if (query.hasMore) {
// Fetch next page
}
}
}
Java
JoinedGroupsByRoleQueryParams params = new JoinedGroupsByRoleQueryParams();
params.setRole(GroupMemberRole.UNDEF);
params.setPageSize(20);
JoinedGroupsByRoleQuery query = GroupChannel.createJoinedGroupsByRoleQuery(params);
query.loadNextPage((result, error) -> {
if (error == null && result != null) {
List<GroupInfo> groups = result.getData();
if (query.hasMore()) {
// Fetch next page
}
}
});