Skip to main content

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
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}")
}
}
}

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
val groupIds = listOf("groupId1", "groupId2")

GroupChannel.getJoinedGroups(groupIds) { groups, error ->
if (error == null && groups != null) {
groups.forEach { group ->
println("Joined group: ${group.groupId}")
}
}
}

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 ValueRole
GroupMemberRole.UNDEFAll roles
GroupMemberRole.NORMALChannel member
GroupMemberRole.MANAGERChannel admin
GroupMemberRole.OWNERChannel owner
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
}
}
}