Skip to main content

Get channels

Chat UI SDK includes built-in channel retrieval and display logic. When you use the default ChannelListFragment or ChannelFragment, you do not need to call channel query interfaces directly.

To customize the channel list or apply custom filtering, use the nexconn public API (BaseChannel):

  • BaseChannel.createChannelsQuery(ChannelsQueryParams): Load a paginated channel list
  • BaseChannel.getUnreadChannels(List<ChannelType>, ...): Get channels with unread messages
  • BaseChannel.getChannels(List<ChannelIdentifier>, ...): Get specific channels by identifier

Example

kotlin
val query = BaseChannel.createChannelsQuery(
ChannelsQueryParams(
channelTypes = listOf(ChannelType.DIRECT, ChannelType.GROUP, ChannelType.SYSTEM)
).apply {
pageSize = 20
topPriority = true
}
)

query.loadNextPage { page, error ->
if (error != null) return@loadNextPage
val channels = page?.data.orEmpty()
// Custom channel list rendering
}

BaseChannel.getUnreadChannels(
listOf(ChannelType.DIRECT, ChannelType.GROUP)
) { channels, error ->
if (error == null) {
// Unread channels collection
}
}

val identifier = ChannelIdentifier(ChannelType.DIRECT, "user_001")
BaseChannel.getChannels(listOf(identifier)) { channels, error ->
if (error == null) {
val channel = channels?.firstOrNull()
// Access channel?.draft / channel?.unreadCount / channel?.isPinned etc.
}
}