Retrieve a list of channels
You can retrieve a list of OpenChannel objects using the loadNextPage(completionHandler:) method of an OpenChannelListQuery instance.
On the other hand, a list of GroupChannel objects can be retrieved through GroupChannelCollection and its loadMore() method. First, set GroupChannelListQueryParams and create a GroupChannelListQuery instance. Then pass the query to the parameter in createGroupChannelCollection(). 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 channels
Create an OpenChannelListQuery instance to retrieve a list of open channels. If you wish to filter open channels, set OpenChannelListQueryParams and pass it into createOpenChannelListQuery(params:). 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 create a group channel collection, set GroupChannelListQueryParams to filter and sort group channels, which is used in createMyGroupChannelListQuery(). Then pass the query instance in the createGroupChannelCollection() method when creating a group channel collection.
To retrieve group channels in the collection, call hasMore first to check whether there are more channels to load. 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 create a GroupChannelListQuery instance first and set its params. The params in GroupChannelListQuery works much like other search options, retrieving group channels based on the values set to the params. 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 state. To retrieve a list of Supergroup channels only, you can set the superChannelFilter property to SuperChannelFilter.super.
Once the params within GroupChannelListQuery is set, you can pass the query instance to query in createGroupChannelCollection() as instructed in the previous section.
GroupChannelListQueryParams
This table only contains properties shown in the code above. To see the comprehensive list of all available methods and properties, see GroupChannelListQueryParams in API reference.
| Property name | Type | Description |
|---|---|---|
includeEmptyChannel | 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 |