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

Filter group channels by user IDs

To filter group channels by user IDs, use the userIdsExactFilter or userIdsIncludeFilter filter. 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.

A userIdsExactFilter filter 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 1-to-1 group channels with the specified user.

val query = GroupChannel.createMyGroupChannelListQuery(
    GroupChannelListQueryParams().apply {
        userIdsExactFilter = listOf("John", "Jay")
    }
)
query.next { channels, e ->
    // Only Channel A is returned in a result list 
    // through the list parameter of the callback method.
}

The 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.

val query = GroupChannel.createMyGroupChannelListQuery(
    GroupChannelListQueryParams().apply {
        setUserIdsIncludeFilter(listOf("John", "Jay", "Jin"), QueryType.AND)
    }
)
query.next { channels, e ->
    // Only Channel B containing {'John', 'Jay', 'Jin'} as a 
    // subset is returned in a result list.
}

val query = GroupChannel.createMyGroupChannelListQuery(
    GroupChannelListQueryParams().apply {
        setUserIdsIncludeFilter(filter, QueryType.OR)
    }
)
query.next { channels, e ->
    // Channel A and Channel B both have {'John'}, Channel A and Channel B both have {'Jay'}, 
    // and Channel B has {'Jin'}.
    // Both Channel A and Channel B are returned in a result list.
}