Chat / iOS
Chat iOS v4
Chat iOS
Chat
iOS
Home
/
Chat
/
iOS
/
Channel
This is the new Docs for Chat SDK v4 for iOS. To see the previous Docs, click here.

Search group channels by name, URL, or other filters

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


Search public group channels

A GroupChannelListQuery 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 with channelNameContainsFilter, which returns a list of the current user's group channels that partially match the specified keyword in their channel names.

class CustomViewController: ViewController {
    var query: GroupChannelListQuery?
    
    // ...
    
    func createQuery() {
        self.query = GroupChannel.createMyGroupChannelListQuery { params in
            params.includeEmptyChannel = true
            params.setSearchFilter("Sendbird", fields: .channelName)
        }
    }
    
    func loadNextPage() {
        self.query?.loadNextPage { channels, error in
            guard error == nil else {
                // Handle error.
                return
            }

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

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

class CustomViewController: ViewController {
    var query: GroupChannelListQuery?
    
    // ...
    
    func createQuery() {
        self.query = GroupChannel.createMyGroupChannelListQuery { params in
            params.includeEmptyChannel = true
            params.channelURLsFilter = [
                "seminar",
                "lecture"
            ]
        }
    }
    
    func loadNextPage() {
        self.query?.loadNextPage { channels, error in
            guard error == nil else {
                // Handle error.
                return
            }

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

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

List of filters

NameFilters

customTypesFilter

Group channels with one or more specified custom types.

customTypeStartsWithFilter

Group channels with a custom type that starts with the specified value.

channelNameContainsFilter

Group channels that contain the specified value in their names.

channelURLsFilter

Group channels with one or more specified channel URLs.

superChannelFilter

Either super or nonsuper group channels.

publicChannelFilter

Either public or private group channels.

unreadChannelFilter

Group channels with one or more unread messages.

channelHiddenStateFilter

Group channels with the specified hidden state and operating behavior.

myMemberStateFilter

Group channels based on whether the user has accepted an invitation, or whether the user was invited by a friend.

userIdsExactFilter

Group channels that contain members with one or more specified user IDs.

userIdsIncludeFilter

Group channels that include one or more members with the specified user IDs.

nicknameContainsFilter

Group channels with members whose nicknames contain the specified value.

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.


Search private group channels

A PublicGroupChannelListQuery instance provides several 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 with channelNameContainsFilter, which returns a list of the current user's group channels that partially match the specified keyword in their channel names.

class CustomViewController: ViewController {
    var query: PublicGroupChannelListQuery?
    
    // ...
    
    func createQuery() {
        self.query = GroupChannel.createPublicGroupChannelListQuery { params in
            params.includeEmptyChannel = true
        }
    }
    
    func loadNextPage() {
        self.query?.loadNextPage { channels, error in
            guard error == nil else {
                // Handle error.
                return
            }

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

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

class CustomViewController: ViewController {
    var query: PublicGroupChannelListQuery?
    
    // ...
    
    func createQuery() {
        self.query = GroupChannel.createPublicGroupChannelListQuery { params in
            params.includeEmptyChannel = true
                params.channelURLsFilter = [
                    "seminar",
                    "lecture"
                ]
        }
    }
    
    func loadNextPage() {
        self.query?.loadNextPage { channels, error in
            guard error == nil else {
                // Handle error.
                return
            }

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

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

List of filters

NameFilters

customTypesFilter

Group channels with one or more specified custom types.

customTypeStartsWithFilter

Group channels with a custom type that starts with the specified value.

channelNameContainsFilter

Group channels that contain the specified value in their names.

channelURLsFilter

Group channels with the specified channel URLs.

superChannelFilter

Either super or nonsuper group channels.

publicMembershipFilter

Group channels with one or more specified URLs.

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.