/ SDKs / Android
SDKs
Chat SDKs Android v4
Chat SDKs Android
Chat SDKs
Android
Version 4

Search group channels by name, URL, or other filters

Copy link

You can search for specific group channels by using several types of search filters within the GroupChannelListQuery and PublicGroupChannelListQuery classes.


Search private group channels

Copy link

A GroupChannelListQuery instance provides many types of search filters such as channelNameContainsFilter and channelUrlsFilter. You can use these filters to search for specific private group channels.

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

val query = GroupChannel.createMyGroupChannelListQuery(
    GroupChannelListQueryParams().apply {
        includeEmpty = true
        channelNameContainsFilter = "Sendbird"
    }
)
query.next { channels, e ->
    if (e != null) {
        // Handle error.
    }

    // Through the channels parameter of the callback method
    // which the Sendbird server has passed a result list to,
    // a list of group channels that have "Sendbird" 
    // in their names is returned.
}

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

val query = GroupChannel.createMyGroupChannelListQuery(
    GroupChannelListQueryParams().apply {
        includeEmpty = true
        channelUrlsFilter = listOf("seminar", "lecture")
    }
)
query.next { channels, e ->
    if (e != null) {
        // Handle error.
    }

    // Through the channels parameter of the callback method,
    // which the Sendbird server has passed a result list to,
    // a list of group channels that have "seminar" 
    // or "lecture" in their URLs is returned.
}

The following table shows all filters supported in GroupChannelListQuery 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.

hiddenChannelFilter

Group channels with the specified state and operating behavior. You can enable this filter using the hiddenChannelFilter 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 PublicGroupChannelListQuery 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.

val query = GroupChannel.createPublicGroupChannelListQuery(
    PublicGroupChannelListQueryParams().apply {
        includeEmpty = true
        channelNameContainsFilter = "Sendbird"
    }
)
query.next { channels, e ->
    if (e != null) {
        // Handle error.
    }

    // Through the channels parameter of the callback method,
    // which the Sendbird server has passed a result list to,
    // a list of group channels that have "Sendbird" 
    // in their names is returned.
}

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.

val query = GroupChannel.createPublicGroupChannelListQuery(
    PublicGroupChannelListQueryParams().apply {
        includeEmpty = true
        channelUrlsFilter = listOf("seminar", "lecture")
    }
)
query.next { channels, e ->
    if (e != null) {
        // Handle error.
    }

    // Through the channels parameter of the callback method,
    // which Sendbird the server has passed a result list to,
    // a list of group channels that have "seminar" 
    // or "lecture" in their URLs is returned.
}

The following table shows all filters supported in PublicGroupChannelListQuery 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.

membershipFilter

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 GroupChannelListQuery's superChannelFilter() method. A Supergroup channel is determined by the groupChannel.isSuper property. If the property has a value of true, the channel is a Supergroup channel.

val query = GroupChannel.createMyGroupChannelListQuery(
    GroupChannelListQueryParams().apply {
        superChannelFilter = SuperChannelFilter.SUPER_CHANNEL_ONLY
    }
)
query.next { channels, e ->
    if (e != null) {
        // Handle error.
    }

    // A list of matching group channels is successfully retrieved.
    // Through the list parameter of the callback method,
    // you can access the data of each group channel from the result list that 
    // the Sendbird server has passed to the callback method.
}