Retrieve a list of channels
You can retrieve a list of OpenChannel
objects using the loadNextPage(completionHandler:)
method of an OpenChannelListQuery
instance and a list of GroupChannel
objects using the loadNextPage(completionHandler:)
method of a GroupChannelListQuery
instance. The GroupChannelListQuery
instance returns both public and private group channels that the current user has joined. To retrieve a list of all public group channels regardless of the current user's membership status, use the PublicGroupChannelListQuery
instance as described later on 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 matching the specifications set by 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
Create a GroupChannelListQuery
instance to retrieve a list of group channels matching the specifications set by GroupChannelListQueryParams
.
You can set the GroupChannelListQueryParams
's includeEmpty
property to true
to allow users to view empty channels, which include channels that are empty because the view chat history option is turned off to prevent new members from seeing previous conversations. You can determine whether to turn on the chat history option on Sendbird Dashboard
After a list of group channels is successfully retrieved, you can access the data of each channel from the result list through the channels parameter of the callback handler.
All public group channels
If you want to retrieve a list of all public group channels regardless of the current user's membership status, use the loadNextPage(completionHandler:)
method of a PublicGroupChannelListQuery
instance and set membershipFilter
to MembershipFilter.ALL
in PublicGroupChannelListQueryParams
.
After a list of public group channels is successfully retrieved, you can access the data of each channel from the result list through the channels
parameter of the callback handler.
Supergroup channels
To retrieve a list of Supergroup channels, you can set the superChannelFilter
property to .super
in either the GroupChannelListQuery
or PublicGroupChannelListQuery
instance. The superChannelFilter
property works much like other search filters. Use GroupChannelListQuery
when only searching for group channels that the current user belongs to, and use PublicGroupChannelListQuery
when searching for all public group channels regardless of the current user's membership status.
When queried channels are returned, you can check if the channel is a Supergroup channel by looking at whether the isSuper
property has a value of true
.