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

Search group channels by name, URL, or other filters

Copy link

You can search for specific group channels by adding keywords to a SbGroupChannelListQuery instance. There are three types of keywords that can be used: name, URL, and custom type.


Search private group channels

Copy link

A SbGroupChannelListQuery instance provides many types of search filters such as ChannelNameContainsFilter and ChannelUrlsFilter filters.

The code sample below shows the query instance which returns a list of group channels that partially match the specified ChannelNameContainsFilter keyword in their channel names.

SbGroupChannelListQueryParams queryParams = new SbGroupChannelListQueryParams();
queryParams.ChannelNameContainsFilter = "Sendbird";

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

The following shows the query instance which returns a list of group channels that partially match the specified ChannelUrlsFilter keyword in their channel URLs.

SbGroupChannelListQueryParams queryParams = new SbGroupChannelListQueryParams();
queryParams.ChannelUrlsFilter = new List { "seminar" };

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

You can also search for group channels with a specific custom type by setting CustomTypesFilter as in the following code.

SbGroupChannelListQueryParams queryParams = new SbGroupChannelListQueryParams();
queryParams.CustomTypesFilter = new List { "movie" };

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

The following table shows all filters supported in SbGroupChannelListQuery to search for specific channels you want to retrieve. You can use any of the filters in a similar fashion with the sample code above.

List of filters

Copy link
NameFilters

CustomTypesFilter

Group channels with one or more specified custom types. You can enable this filter using the CustomTypesFilter property.

CustomTypeStartsWithFilter

Group channels with a custom type that starts with the specified value. You can enable this filter using the CustomTypeStartsWithFilter property.

ChannelNameContainsFilter

Group channels that contain the specified value in their names. You can enable this filter using the ChannelNameContainsFilter property.

ChannelUrlsFilter

Group channels with one or more specified channel URLs. You can enable this filter using the ChannelUrlsFilter property.

SuperChannelFilter

Either super or nonsuper group channels. Using the SuperChannelFilter property, you can enable this filter.

PublicChannelFilter

Either public or private group channels. Using the PublicChannelFilter property, you can enable this filter.

UnreadChannelFilter

Group channels with one or more unread messages. Using the UnreadChannelFilter property, you can enable this filter.

ChannelHiddenStateFilter

Group channels with the specified state and operating behavior. You can enable this filter using the ChannelHiddenStateFilter property.

MyMemberStateFilter

Group channels based on whether the user has accepted an invitation. You can enable this filter using the MyMemberStateFilter property.

UserIdsExactFilter

Group channels that contain members with one or more specified user IDs. You can enable this filter using the UserIdsExactFilter property.

UserIdsIncludeFilter

Group channels that include one or more members with the specified user IDs. You can enable this filter using the UserIdsIncludeFilter property.

NicknameContainsFilter

Group channels with members whose nicknames contain the specified value. You can enable this filter using the NicknameContainsFilter property.

MetaDataOrderKeyFilter

Group channels with metadata containing an item with the specified value as its key. This filter is effective only when the metadata are sorted in alphabetical order. You can enable this filter using the MetaDataOrderKeyFilter property.


Search public group channels

Copy link

A SbPublicGroupChannelListQuery instance provides many types of search filters such as ChannelNameContainsFilter and ChannelUrlsFilter. You can use these filters to search for specific public group channels.

The sample code below shows the query instance, which returns the current user's public group channels that partially match the specified keyword in ChannelNameContainsFilter in their channel names.

SbPublicGroupChannelListQueryParams queryParams = new SbPublicGroupChannelListQueryParams();
queryParams.ChannelNameContainsFilter = "Sendbird";

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

The following shows the query instance, which returns a list of the current user's group channels that partially match the specified keyword in ChannelUrlsFilter in their channel URLs.

SbPublicGroupChannelListQueryParams queryParams = new SbPublicGroupChannelListQueryParams();
queryParams.ChannelUrlsFilter = new List { "seminar" };

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

The following table shows all filters supported in SbPublicGroupChannelListQuery to search for specific channels you want to retrieve. You can use any of the filters in a similar fashion with the sample code above.

List of filters

Copy link
NameFilters

CustomTypesFilter

Group channels with one or more specified custom types. You can enable this filter using the CustomTypesFilter property.

CustomTypeStartsWithFilter

Group channels with a custom type that starts with the specified value. You can enable this filter using the CustomTypeStartsWithFilter property.

ChannelNameContainsFilter

Group channels that contain the specified value in their names. You can enable this filter using the ChannelNameContainsFilter property.

ChannelUrlsFilter

Group channels with one or more specified channel URLs. You can enable this filter using the ChannelUrlsFilter property.

SuperChannelFilter

Either super or nonsuper group channels. Using the SuperChannelFilter property, you can enable this filter.

PublicMembershipFilter

Specifies public group channels to retrieve based on membership. Acceptable values are All and Joined. If set to All, retrieves both channels where the current user is and isn't a member. If set to Joined, retrieves only channels where the current user is a member. (Default: Joined)

MetaDataOrderKeyFilter

Group channels with metadata containing an item with the specified value as its key. This filter is effective only when the metadata are sorted in alphabetical order. You can enable this filter using the MetaDataOrderKeyFilter property.


Retrieve a list of Supergroup channels using a filter

Copy link

You can retrieve a list of Supergroup channels through the SbGroupChannelListQuery's SuperChannelFilter property. A Supergroup channel is determined by the groupChannel.IsSuper property. If the property has a value of true, the channel is a Supergroup channel.

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

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