# UIKIt Channel and User Filters

**URL:** <https://community.sendbird.com/t/uikit-channel-and-user-filters/711>\
**Category:** Sendbird Chat UIKit\
**Tags:** android, ios, javascript, uikit\
**Created:** [July 29, 2020, 9:11pm UTC](https://community.sendbird.com/t/uikit-channel-and-user-filters/711 "2020-07-29T21:11:39Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![Eric](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/eric/32/380_2.png) [@Eric](https://community.sendbird.com/u/Eric)\
**Post date:** [July 29, 2020, 9:11pm UTC](https://community.sendbird.com/t/uikit-channel-and-user-filters/711/1 "2020-07-29T21:11:39Z")

</div>

I am looking at UIKit samples and need to be able to filter group channels by custom type (actually would prefer to filter by meta data key and value, but looks like that only supports filter by key and not filter by both key and value). Also I have a user filter case as well.

This is a specific example in iOS that I am attempting, but I also need to be able to do the same in Android and also on the web site.

**1. Filter Group Channels by Custom Type:**

In iOS, I want to present a SBUChannelListViewController and update the channelListQuery SBDGroupChannelListQuery to provide the filtered list when the view controller appears. However, it seems that that functionality is not exposed. Meaning I don’t see how I can modify the query by either making a series of method calls or deriving a new class based on SBUChannelListViewController to override functionality.

This is to support the scenario where our users belong to one or more communities and the user will have a specific community selected in our app. So when a user is pulling up the chat for the current community, I need to make sure group channels returned for the user are also group channels in a specific community (custom type).

**2. Filter Users**

When a user wants to create a new conversation, I want to be able to provide a list of users with multiple sections. The example of sections I am using are: 1) Admins, 2) Friends, 3) Others. Is this possible in UIKit to be able to provide a custom sectioned contact list? Also I would also be applying the currently selected community that the connected chat user is in when gathering the possible chat contacts to create a conversation with.

---

<div class="post-metadata">

**Author:** ![eric.kim](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/eric.kim/32/8_2.png) [@eric.kim](https://community.sendbird.com/u/eric.kim)\
**Post date:** [July 29, 2020, 10:29pm UTC](https://community.sendbird.com/t/uikit-channel-and-user-filters/711/2 "2020-07-29T22:29:09Z")

</div>

@Eric

Would this guide help?

[How to filter channel using custom-type - External.pdf](https://community.sendbird.com/uploads/short-url/9rJi0Y3FmQYgJjR7FiSXtHqrgy0.pdf) (204.2 KB)

---

<div class="post-metadata">

**Author:** ![Doo\_Rim](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/doo_rim/32/239_2.png) [@Doo\_Rim](https://community.sendbird.com/u/Doo_Rim)\
**Post date:** [July 30, 2020, 12:28am UTC](https://community.sendbird.com/t/uikit-channel-and-user-filters/711/3 "2020-07-30T00:28:36Z")

</div>

Hi, I am Android developer for UIKit.

1. We provide custom type as a List of String. I think you can define your type for group channel as each strings.

2. I am sorry that I didn’t understand what community means. We don’t support the relationship among users yet. I think you can build the relationship of users in your applications and apply this to your custom views. You can check the Android custom sample below link.  
[https://github.com/sendbird/SendBird-Android/tree/master/uikit/uikit-custom-sample](https://github.com/sendbird/SendBird-Android/tree/master/uikit/uikit-custom-sample)

---

<div class="post-metadata">

**Author:** ![Eric](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/eric/32/380_2.png) [@Eric](https://community.sendbird.com/u/Eric)\
**Post date:** [July 30, 2020, 12:32am UTC](https://community.sendbird.com/t/uikit-channel-and-user-filters/711/4 "2020-07-30T00:32:24Z")

</div>

Thanks, I read the guide you posted and it is the concept I am attempting to do in iOS, Android UIKit. I am looking at iOS currently and do not see how I can modify the search query in the SBUChannelListViewController.

There is an instance variable, channelListQuery, that I would like to be able to override as the default query by adding 1 additional criteria which is the custom type. So far I do not see an interface for being able to modify the query. Also I would like this filter to always be applied when I use that viewcontroller.

---

<div class="post-metadata">

**Author:** ![Eric](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/eric/32/380_2.png) [@Eric](https://community.sendbird.com/u/Eric)\
**Post date:** [July 30, 2020, 5:51pm UTC](https://community.sendbird.com/t/uikit-channel-and-user-filters/711/5 "2020-07-30T17:51:52Z")

</div>

Thank you for the Android resources. I should add that I am also using Xamarin and so far have not created a binding library successfully for Android UIKit. So I have not been able to test the scenario on Android yet.

I have been able to create a Xamarin binding to a proxy library on iOS, and so I am able to attempt the custom filter on iOS. However, I have become stuck in not seeing a way to apply the channel type filter in iOS UIKit because the variable I need is not exposed. Am I missing some other method call that I need? Can you recommend a specific code sample that shows applying a filter on channel type in iOS UIKit. This is what I am trying to do:

1. Create a SBUChannelListViewController instance
2. Set the custom channel type filter
3. Present or Push the created SBUChannelListViewController
4. Verify that the created SBUChannelListViewController is now presented and the group channels returned are the expected channels of the custom type

---

<div class="post-metadata">

**Author:** ![Eric](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/eric/32/380_2.png) [@Eric](https://community.sendbird.com/u/Eric)\
**Post date:** [July 31, 2020, 6:48pm UTC](https://community.sendbird.com/t/uikit-channel-and-user-filters/711/6 "2020-07-31T18:48:21Z")

</div>

@eric.kim

Is what I am attempting to do possible in UIKit currently? I want to use UIKit so I can avoid building layouts and UIKit looks to have all the layouts I need.

The only change I need to make aside from adjusting the styles is to add a custom type group channel filter to the channelListQuery. When I look at the SDK, I can see how to do this to get a list of group channels filtered by custom channel type for my user. However, when I attempt to do this in UIKit, it looks like the functionality I need exists and is named channelListQuery, but that I cannot access that variable and attempt to modify the default group channel list returned. My goal is to verify if this is possible with UIKit on iOS, Android, and Web.

We have a DB where we define the relationships between users and communities and we can assign the communities as custom group channels in SendBird. Then we will be able to use the functionality we have defined by simply adding the custom group channel type to the channel list queries so that whenever a user gets a list of channels, it will filter by the custom group channel that we will store on our side. Also when we create a group channel we will assign this custom channel type at that time.

So in summary, I want to use UIKit but need to always filter by a custom group channel type. There will be no cases where I need to return all of a user’s group channels. Instead, I will only return a filtered custom group channel list that I will maintain on my side (I will just need to be able to pass in the CurrentGroupChannelType filter string in order to get the list of group channels I need for the logged in user.

Thanks

---

<div class="post-metadata">

**Author:** ![Tez](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/tez/32/146_2.png) [@Tez](https://community.sendbird.com/u/Tez)\
**Post date:** [August 3, 2020, 3:47am UTC](https://community.sendbird.com/t/uikit-channel-and-user-filters/711/7 "2020-08-03T03:47:15Z")

</div>

Hello @Eric, sorry for the late checking!

I will answer about 4 things. And I’d like to ask you about the parts that need additional confirmation.

1. _Create a SBUChannelListViewController instance_

2. Set the custom channel type filter

3. _Present or Push the created SBUChannelListViewController_

4. _Verify that the created SBUChannelListViewController is now presented and the group channels returned are the expected channels of the custom type_

- And last, please check this code for a sample of filter users.
  - `/Customize/Manager/Features/InviteUserCustomManager.swift` -\> **func userListCustom()**
  - You can use the user list filtered directly when initializing `SBUInviteUserViewController`.
  - Unfortunately, `SBUInviteUserViewController` does not support query customizing.

This is the UIKit iOS sample GitHub link.

> **[sendbird/UIKit-iOS-Swift](https://github.com/sendbird/uikit-ios-swift)**
>
> Sendbird-UIKit-iOS-Swift-Sample. Please visit https://community.sendbird.com for any questions! - sendbird/UIKit-iOS-Swift

Please feel free to mention me if you need additional questions or more information!

---

<div class="post-metadata">

**Author:** ![Sravan\_S](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/sravan_s/32/83_2.png) [@Sravan\_S](https://community.sendbird.com/u/Sravan_S)\
**Post date:** [August 3, 2020, 5:11am UTC](https://community.sendbird.com/t/uikit-channel-and-user-filters/711/8 "2020-08-03T05:11:28Z")

</div>

Hi Eric, I am from React/JS team

As far as I understand, you have 2 use cases

**1. Filter Group Channels by Custom Type:**

> “…our users belong to one or more communities and the user will have a specific community selected in our app. So when a user is pulling up the chat for the current community, I need to make sure group channels returned for the user are also group channels in a specific community (custom type).”

I think this is possible with some tweaking, let me get back to you with a sample for this

**2. Filter Users**

> When a user wants to create a new conversation, I want to be able to provide a list of users with multiple sections

This case, I think might not be possible to support by default, you might have to create your own component to do this

Anyways, let me get back to you with samples in codesandbox(might take 1-2 days)  
I hope its not confusing that many people are replying you at the sametime ☹

---

<div class="post-metadata">

**Author:** ![Doo\_Rim](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/doo_rim/32/239_2.png) [@Doo\_Rim](https://community.sendbird.com/u/Doo_Rim)\
**Post date:** [August 3, 2020, 6:33am UTC](https://community.sendbird.com/t/uikit-channel-and-user-filters/711/9 "2020-08-03T06:33:05Z")

</div>

For Android, How to implement custom channel type creation, query.

1. You can create a channel with params. Please refer to `CustomCreateChannelFragment` class in our sample code

```auto
    @Override
    protected void onBeforeCreateGroupChannel(@NonNull GroupChannelParams params) {
        super.onBeforeCreateGroupChannel(params);
        params.addUserIds(userIds)
                .setCustomType("your type");
    }

```

1. You can query your custom type channel. Please refer to `CustomChannelListActivity` class in our sample code

```auto
    @Override
    protected ChannelListFragment createChannelListFragment() {
        GroupChannelListQuery groupChannelListQuery = GroupChannel.createMyGroupChannelListQuery();
        groupChannelListQuery.setCustomTypesFilter(yourTypeList);

    return new ChannelListFragment.Builder(R.style.CustomChannelListStyle)
            .setGroupChannelListQuery(groupChannelListQuery)
            .build();
    }

```

If you want to set your custom user list, please refer to `BaseApplication.getCustomUserListQuery()` in our custom sample.

---

<div class="post-metadata">

**Author:** ![Eric](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/eric/32/380_2.png) [@Eric](https://community.sendbird.com/u/Eric)\
**Post date:** [August 3, 2020, 11:44pm UTC](https://community.sendbird.com/t/uikit-channel-and-user-filters/711/10 "2020-08-03T23:44:39Z")

</div>

@Tez  
Thank you, that is what I was looking for. I seemed to have not had that exact version of the sample where the the query filter was exposed. I was able to update and verify I have the latest and used the strings you referenced to locate those examples.

@Doo_Rim  
Thank you that is the Android sample that I was looking for. I am working through iOS first and then will try your example and let you know if I have any problems.

---

<div class="post-metadata">

**Author:** ![Eric](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/eric/32/380_2.png) [@Eric](https://community.sendbird.com/u/Eric)\
**Post date:** [August 3, 2020, 11:45pm UTC](https://community.sendbird.com/t/uikit-channel-and-user-filters/711/11 "2020-08-03T23:45:13Z")

</div>

@Sravan_S  
Thank you for checking on examples for me. I am prepared to make some modifications if needed, but I would also prefer to implement the way you recommend so that I can apply updates more easily. No problem if it takes a couple days to get back to me. I will be testing iOS and Android in the meantime.

Sorry I had to make a second post in order to mention more than two people.

---

<div class="post-metadata">

**Author:** ![Eric](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/eric/32/380_2.png) [@Eric](https://community.sendbird.com/u/Eric)\
**Post date:** [August 6, 2020, 2:30am UTC](https://community.sendbird.com/t/uikit-channel-and-user-filters/711/12 "2020-08-06T02:30:59Z")

</div>

@Tez

I was able to successfully filter my group channel list by channel type following your example in my app.

I revisited your sample app from: [https://github.com/sendbird/UIKit-iOS-Swift](https://github.com/sendbird/UIKit-iOS-Swift) , and ran into some build errors after following the instructions listed. Previously I had run your sample, but I must have been on an older version. So I have been unsuccessful attempting to build the latest sample.

Now I have confirmed to have:

- SendBirdSDK (3.0.195)
- SendBirdUIKit (1.1.2):
- COCOAPODS: 1.7.5
- Xcode Version 11.3.1 (11C504).

I had errors described in this section: Unknown attribute error handling. After making the pre-action build script, I have the following 5 remaining build errors.

**SendBirdUIKit-Sample Group**

**Swift Compiler Error Group**

**/SB.iOS/SendBirdUIKit-Sample/Customize/Manager/Features/ChannelListCustomManager.swift:58:45: Cannot invoke initializer for type ‘CustomChannelListCell’ with no arguments**

**/SB.iOS/SendBirdUIKit-Sample/Customize/Manager/Features/ChannelListCustomManager.swift:58:45: Overloads for ‘CustomChannelListCell’ exist with these partially matching parameter lists: (coder: NSCoder), (style: UITableViewCell.CellStyle, reuseIdentifier: String?)**

**/SB.iOS/SendBirdUIKit-Sample/Customize/Manager/Features/ChannelCustomManager.swift:48:59: Missing argument for parameter ‘frame’ in call**

**/SB.iOS/SendBirdUIKit-Sample/Customize/View/Channel/SubView/CustomNewMessageInfo.swift:12:47: ‘init(frame:)’ declared here**

**/SB.iOS/SendBirdUIKit-Sample/Customize/Manager/Features/ChannelCustomManager.swift:52:45: Missing argument for parameter ‘frame’ in call**

**/SB.iOS/SendBirdUIKit-Sample/Customize/View/Common/CustomEmptyView.swift:14:14: ‘init(frame:)’ declared here**

**/SB.iOS/SendBirdUIKit-Sample/Customize/Manager/Features/ChannelCustomManager.swift:91:49: Cannot invoke initializer for type ‘CustomUserMessageCell’ with no arguments**

**/SB.iOS/SendBirdUIKit-Sample/Customize/Manager/Features/ChannelCustomManager.swift:91:49: Overloads for ‘CustomUserMessageCell’ exist with these partially matching parameter lists: (coder: NSCoder), (style: UITableViewCell.CellStyle, reuseIdentifier: String?)**

**/SB.iOS/SendBirdUIKit-Sample/Customize/Manager/Features/ChannelListCustomManager.swift:46:41: Missing argument for parameter ‘frame’ in call**

Please let me know if there is something I am missing. My goal is to build your latest ios sample app.

Thanks

---

<div class="post-metadata">

**Author:** ![Tez](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/tez/32/146_2.png) [@Tez](https://community.sendbird.com/u/Tez)\
**Post date:** [August 6, 2020, 9:02am UTC](https://community.sendbird.com/t/uikit-channel-and-user-filters/711/13 "2020-08-06T09:02:45Z")

</div>

Hi @Eric!

The problem you have reported is the problem related to the initializer in Swift5.1 and earlier versions. There has been a change in the initializer in Apple since Swift5.2 version.  
But I think that’s a problem that can happen to other developers, too.  
So, the problem that occurred in the lower version was fixed and updated quickly thanks to your report! Thank you for finding the problem.

Please update the sample project and retest it. 😃

---

<div class="post-metadata">

**Author:** ![Eric](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/eric/32/380_2.png) [@Eric](https://community.sendbird.com/u/Eric)\
**Post date:** [August 6, 2020, 5:12pm UTC](https://community.sendbird.com/t/uikit-channel-and-user-filters/711/14 "2020-08-06T17:12:46Z")

</div>

Thanks @Tez!

I was able to update and run the sample.

I did get a link error when building:

ld: library not found for -lPods-SendBirdUIKit-Sample

So I removed that framework reference and was able to launch the app. I am now testing the sample features.

Thanks

---

<div class="post-metadata">

**Author:** ![Eric](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/eric/32/380_2.png) [@Eric](https://community.sendbird.com/u/Eric)\
**Post date:** [August 7, 2020, 12:33am UTC](https://community.sendbird.com/t/uikit-channel-and-user-filters/711/15 "2020-08-07T00:33:16Z")

</div>

@Tez Sorry to ask another question, but I am slightly stuck.

I am looking at your sample at customCreateChannelAction on CreateChannelVC\_UserList where I want to override the createchannel action so that I can pass in my parameters to create a channel.

I will be overriding such that I can call the version of createChannel that takes SBDGroupChannelParams. It looks like that is in your sample as a placeholder but not being used all the way yet.

Can you recommend or point me to the way I can override the createChannel method in a ViewController that I derived from SBUCreateChannelViewController so that when the button is pressed to create the group channel with the selected users, that it will call my overridden method so I can pass in the parameters to create the group channel?

Thanks

---

<div class="post-metadata">

**Author:** ![Tez](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/tez/32/146_2.png) [@Tez](https://community.sendbird.com/u/Tez)\
**Post date:** [August 7, 2020, 6:25am UTC](https://community.sendbird.com/t/uikit-channel-and-user-filters/711/16 "2020-08-07T06:25:45Z")

</div>

Hi @Eric,  
Among the functions we provide, those whose access control is of open type are designed for the override.  
And in the case of public type, it is designed to be called from the action you created yourself.  
Currently, the `createChannel(params:)` function can only be called by making a button by itself.

I’ll show you an example of creating a button and calling the `createChannel(params:)` function by setting the parameters directly in the action.

1. First, see Customizing the leftBarButton implemented in the `CreateChannelCustomManager` -\> `uiComponentCustom()` function.

2. Customizing the right bar button in a similar way.

3. Implement a custom function to invoke the `createChannel(params:)` function.

I think this way you can implement what you want 😃

Your inconvenience was a great help to me in implementing UIKit. I will consider this part of the design of the implementation from now on!  
Thanks!

---

<div class="post-metadata">

**Author:** ![Eric](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/eric/32/380_2.png) [@Eric](https://community.sendbird.com/u/Eric)\
**Post date:** [August 8, 2020, 12:05am UTC](https://community.sendbird.com/t/uikit-channel-and-user-filters/711/17 "2020-08-08T00:05:27Z")

</div>

@Tez Thanks! I used your example of creating a button to be able to pass in my custom parameters to createChannel.
