To filter group channels by user IDs, use userIdsExactFilter or userIdsIncludeFilter. Let's assume the ID of the current user is Harry and the user is a member of two group channels.
Channel A consists of Harry, John, and Jay.
Channel B consists of Harry, John, Jay, and Jin.
Channel C consists of Harry, Jay, and Jason.
The userIdsExactFilter returns a list of the current user's group channels containing exactly the queried user IDs. In case you specify only one user ID in the filter, the filter returns a list of the current user's one or more distinct 1-to-1 group channels with the specified user.
classCustomViewController:ViewController{var query:GroupChannelListQuery?funccreateQuery(){self.query =GroupChannel.createMyGroupChannelListQuery { params in// The params object is the GroupChannelListQueryParams class.
params.userIdsExactFilter =["John","Jay"]}}funcloadNextPage(){self.query?.loadNextPage { channels, error inguard error ==nilelse{// Handle error.return}// Only Channel A is returned in a result list// through the channels parameter of the callback method.}}}
A userIdsIncludeFilter filter returns a list of the current user's group channels including the queried user IDs partially and exactly. Two different results can be returned according to the value of the queryType parameter.
classCustomViewController:ViewController{var query:GroupChannelListQuery?funccreateQuery(){self.query =GroupChannel.createMyGroupChannelListQuery { params in// The params object is the GroupChannelListQueryParams class.// The value of queryType is .and.
params.setUserIdsIncludeFilter(["John","Jay"], queryType:.and)}}funcloadNextPage(){self.query?.loadNextPage { channels, error inguard error ==nilelse{// Handle error.return}// Both Channel B and Channel C are returned.// because they have both John and Jay as members.}}}classCustomViewController:ViewController{var query:GroupChannelListQuery?funccreateQuery(){self.query =GroupChannel.createMyGroupChannelListQuery { params in// The params object is the GroupChannelListQueryParams class.// The queryType is .or.
params.setUserIdsIncludeFilter(["John","Jay"], queryType:.or)}}funcloadNextPage(){self.query?.loadNextPage { channels, error inguard error ==nilelse{// Handle error.return}// All of Channel A, Channel B, and Channel C are returned// because each channel has either John or Jay as a member.}}}