/ SDKs / Unity
SDKs
Chat SDKs Unity v4
Chat SDKs Unity
Chat SDKs
Unity
Version 4

Retrieve a list of channels

Copy link

You can retrieve a list of open channels using SbOpenChannelListQuery's LoadNextPage() method, which returns a list of SbOpenChannel objects.

You can also retrieve a list of the current user's private group channels using the LoadNextPage() method of a SbGroupChannelListQuery instance, which returns a list of SbGroupChannel objects. Using the IncludeEmptyChannel property of a SbGroupChannelListQuery instance, you can determine whether to include empty channels in the result. Empty channels are group channels that have been created but don't contain any messages, and thus aren't included in the result by default. However, if you turn off the Chat history option on Sendbird Dashboard, you may retrieve empty channels in the result.

Note: See search group channels by name, URL, or other filters to find out how to search for specific group channels using keywords and filters.


Open channel

Copy link

Create an SbOpenChannelListQuery 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.

SbOpenChannelListQueryParams queryParams = new SbOpenChannelListQueryParams();
SbOpenChannelListQuery query = SendbirdChat.OpenChannel.CreateOpenChannelListQuery(queryParams);
query.LoadNextPage((inChannels, inError) =>
{
    if (inError != null)
        return; // Handle error.

    // A list of open channels is successfully retrieved.
});

Group channel

Copy link

Create a SbGroupChannelListQuery instance to retrieve a list of group channels matching the specifications set by SbGroupChannelListQuery.

You can set SbGroupChannelListQuery's IncludeEmptyChannel property to true so that users can view empty channels since 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 under Settings > Chat > Channels > Group channels.

SbGroupChannelListQueryParams queryParams = new SbGroupChannelListQueryParams();
queryParams.Order = SbGroupChannelListOrder.LatestLastMessage;
queryParams.MyMemberStateFilter = SbMyMemberStateFilter.JoinedOnly;
queryParams.Limit = 10;

SbGroupChannelListQuery query = SendbirdChat.GroupChannel.CreateMyGroupChannelListQuery(queryParams);
query.LoadNextPage((inChannels, inError) =>
{
    if (inError != null)
        return; //Handle error.

    // A list of private group channels matching the list query criteria is successfully retrieved.
});

List of properties

Copy link
Property nameTypeDescription

IncludeEmptyChannel

bool

Determines whether to include empty group channels in the results.

MyMemberStateFilter

SbMyMemberStateFilter

Restricts the search scope based on the state of the current user. Acceptable values are All, JoinedOnly, and InvitedOnly.

Order

SbGroupChannelListOrder

A list of user IDs invited to the channel. Acceptable values are Chronological, LatestLastMessage, ChannelNameAlphabetical, and ChannelMetaDataValueAlphabetical.

Limit

int

Specifies the number of results to return per call. Acceptable values are 1 to 100, inclusive. The recommended value for this parameter is 20.


All public group channels

Copy link

If you want to retrieve a list of all public group channels regardless of the current user's membership status, use the SbPublicGroupChannelListQuery instance and set SbPublicGroupChannelMembershipFilter to SbPublicGroupChannelMembershipFilter.all in SbPublicSbGroupChannelListQuery.

After a list of public group channels is successfully retrieved, you can access the data of each channel from the result list.


Supergroup channels

Copy link

To retrieve a list of Supergroup channels, you can set the SuperChannelFilter property to SbGroupChannelSuperChannelFilter.SuperChannelOnly in either the SbGroupChannelListQuery or SbPublicGroupChannelListQuery instance. The SuperChannelFilter property works much like other search filters. Use SbGroupChannelListQuery when only searching for group channels that the current user belongs to, and use SbPublicGroupChannelListQuery 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.

Using SbGroupChannelListQuery

Copy link
SbGroupChannelListQueryParams queryParams = new SbGroupChannelListQueryParams();
queryParams.SuperChannelFilter = SbGroupChannelSuperChannelFilter.SuperChannelOnly;

SbGroupChannelListQuery query = SendbirdChat.GroupChannel.CreateMyGroupChannelListQuery(queryParams);
query.LoadNextPage((inChannels, inError) =>
{
    if (inError != null)
        return; // Handle error.
});

Using SbPublicGroupChannelListQuery

Copy link
SbPublicGroupChannelListQueryParams queryParams = new SbPublicGroupChannelListQueryParams();
SbPublicGroupChannelListQuery query = SendbirdChat.GroupChannel.CreatePublicGroupChannelListQuery(queryParams);

query.LoadNextPage((inChannels, inError) =>
{
    if (inError != null)
        return; //Handle error.
});