Retrieve a list of channels
You can retrieve a list of OpenChannel
instances using the next()
method of an OpenChannelListQuery
instance.
On the other hand, a list of GroupChannel
instances can be retrieved through GroupChannelCollection
and its loadMore()
method. First, create a GroupChannelCollectionParams
object. Then pass it to createGroupChannelCollection()
as an argument. To retrieve a list of certain group channels such as public group channels or Supergroup channels, use the params as described at the bottom of this page.
Note: You can also search for specific open channels and group channels with keywords and filters.
Open channels
Create an OpenChannelListQuery
instance to retrieve a list of open channels. If you wish to filter open channels, set OpenChannelListQueryParams
. After a list of open channels is successfully retrieved, you can access the data of each open channel from the result list through the channels
parameter of the callback handler.
Group channels
A group channel list view can be drawn with a GroupChannelCollection
instance. In order to filter and sort group channels when creating a group channel collection, set GroupChannelCollectionParams
, which can be passed into createGroupChannelCollection()
. Or you can create a GroupChannelFilter
instance before setting the params.
To retrieve group channels in the collection, call hasMore
first to check whether there are more channels to load for the collection. If so, call loadMore()
.
To learn more about how the collection works, see Group channel collection under Local caching.
Filter group channels using GroupChannelFilter
When creating a GroupChannelCollection
instance, you can create a GroupChannelFilter
instance to filter and sort group channels in the collection. Once they are set, you can either pass the instance to filter
in GroupChannelCollectionParams
, or use it directly in createGroupChannelCollection()
. The filter works much like other search options, retrieving a list of group channels matching the specifications. For example, use myMemberStateFilter
when searching for only the group channels that the current user belongs to, and publicChannelFilter
regardless of the current user's membership state. To retrieve a list of Supergroup channels only, you can set the superChannelFilter
property to SuperChannelFilter.SUPER
.
GroupChannelFilter
This table only shows the properties of the class. To see the comprehensive list of all available methods and properties, see GroupChannelFilter in API reference.
Property name | Type | Description |
---|---|---|
includeEmpty | boolean | Determines whether the list includes empty group channels that don't show any messages sent before the current user joins it because the chat history option is turned off. You can turn on or off the chat history option under Settings > Chat > Channels > Group channels on Sendbird Dashboard. |
superChannelFilter | Determines which group channels to include in the list based on their | |
publicChannelFilter | Determines which group channels to include in the list based on their |