Retrieve a list of channels
You can retrieve a list of OpenChannel
objects using the next()
method of an OpenChannelListQuery
instance.
On the other hand, a list of GroupChannel
objects can be retrieved through GroupChannelCollection
and its loadMore()
method. First, create a GroupChannelListQuery
instance. The GroupChannelListQuery
instance returns both public and private group channels that the current user has joined. To retrieve a list of certain group channels such as public group channels or Supergroup channels, use the the list query's filters 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 channel
Create an OpenChannelListQuery
instance to retrieve a list of open channels matching the specifications set by OpenChannelListQuery
. After a list of open channels is successfully retrieved, you can access the data of each open channel from the result list through the openChannel
parameter of the callback method.
Group channels
A group channel list view can be drawn with a GroupChannelCollection
instance. First, create a GroupChannelListQuery
instance. This determines which channel to include in the channel list and how to list channels in order.
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 GroupChannelListQuery
When creating a GroupChannelCollection
instance, you need to set params within GroupChannelListQuery
first. The params in GroupChannelListQuery
works much like other search options, retrieving a list of group channels matching the specifications set by properties in the query instance. For example, use myMemberStateFilter
when searching for only the group channels that the current user belongs to, and publicChannelFilter
when searching for all public group channels regardless of the current user's membership status. To retrieve a list of Supergroup channels, you can set the superChannelFilter
property to SuperChannelFilter.superChannelOnly
.
Once the params is set, you can use the query instance for query
parameter in GroupChannelCollection
constructor.
GroupChannelListQuery
This table only contains properties shown in the code above. To see the comprehensive list of all available methods and properties, see GroupChannelListQuery in API reference.
Property name | Type | Description |
---|---|---|
includeEmpty | bool | 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. |
order | enum | Determines how to order the channels. Acceptable values are |
publicChannelFilter | enum | Determines which group channels to include in the list based on their |
superChannelFilter | enum | Determines which group channels to include in the list based on their |