Skip to main content
Version: v5

Users

Overview

The Users is a Component, showcasing an accessible list of all available users. It provides an integral search functionality, allowing you to locate any specific user swiftly and easily. For each user listed, the widget displays the user's name by default, in conjunction with their avatar when available. Furthermore, it includes a status indicator, visually informing you whether a user is currently online or offline.

Image

The Users component is composed of the following BaseComponents:

ComponentsDescription
ListBasea reusable container component having title, search box, customisable background and a List View
ListItema component that renders data obtained from a User object on a Tile having a title, subtitle, leading and trailing view

Usage

Integration

As CometChatUsers is a custom view controller, it can be launched directly by user actions such as button clicks or other interactions. It's also possible to integrate it into a tab view controller. CometChatUsers offers several parameters and methods for UI customization.

let cometChatUsers = CometChatUsers()
let naviVC = UINavigationController(rootViewController: cometChatUsers)
self.present(naviVC, animated: true)

Actions

Actions dictate how a component functions. They are divided into two types: Predefined and User-defined. You can override either type, allowing you to tailor the behavior of the component to fit your specific needs.

  1. set(onItemClick:)

set(OnItemClick:) is triggered when you click on a ListItem of the users component. This set(OnItemClick:) method proves beneficial when a user intends to customize the on-click behavior in CometChatUsers.

cometChatUsers.set(onItemClick: { user, indexPath in
// Override on item click
})


  1. set(OnItemLongClick:)

set(OnItemLongClick:) is triggered when you long press on a ListItem of the users component. This set(OnItemLongClick:) method proves beneficial when a user intends to additional functionality on long press on list item in CometChatUsers.

cometChatUsers.set(onItemLongClick: { user, indexPath in
// Override on item click
})


3. set(onBack:)

This set(onBack:) method becomes valuable when a user needs to override the action triggered upon pressing the back button in CometChatUsers.

cometChatUsers.set(onBack: {
// Override on back
})

4. set(onSelection:)

The set(onSelection:) only gets trigger when selection mode is set to multiple of single. And this gets trigger on every selection, and returns the list of selected users.


cometChatUsers.set(onSelection: { users in
//Handle action
})


5. set(onError:)

This method proves helpful when a user needs to customize the action taken upon encountering an error in CometChatUsers.

cometChatUsers.set(onError: { error in
// Override on error
})


6. set(onEmpty:)

This set(onEmpty:) method is triggered when the users list is empty in CometChatUsers.

cometChatUsers.set(onEmpty: {
// Handle empty state
})


7. setOnLoad

This set(onLoad:) gets triggered when a user list is fully fetched and going to displayed on the screen, this return the list of users to get displayed on the screen.

cometChatUsers.set(onLoad: { users in
// Handle loaded users
})


Filters

Filters allow you to customize the data displayed in a list within a Component. You can filter the list based on your specific criteria, allowing for a more customized. Filters can be applied using RequestBuilders of Chat SDK.

1. UserRequestBuilder

The UserRequestBuilder enables you to filter and customize the user list based on available parameters in UserRequestBuilder. This feature allows you to create more specific and targeted queries when fetching users. The following are the parameters available in UserRequestBuilder

MethodsTypeDescription
setLimitintsets the number users that can be fetched in a single request, suitable for pagination
setSearchKeywordStringused for fetching users matching the passed string
hideBlockedUsersboolused for fetching all those users who are not blocked by the logged in user
friendsOnlyboolused for fetching only those users in which logged in user is a member
setRoles[String]used for fetching users containing the passed tags
setTags[String]used for fetching users containing the passed tags
withTagsboolused to fetch tags data along with the list of users.
setStatusCometChat.UserStatusused for fetching users by their status online or offline
setUIDs[String]used for fetching users containing the passed users

Example

In the example below, we are applying a filter to the UserList based on Friends.

let usersRequestBuilder = UsersRequest.UsersRequestBuilder(limit: 20).friendsOnly(true)

let usersWithMessages = CometChatUsersWithMessages(usersRequestBuilder: usersRequestBuilder)
let naviVC = UINavigationController(rootViewController: usersWithMessages)
self.present(naviVC, animated: true)
2. SearchRequestBuilder

The SearchRequestBuilder uses UserRequestBuilder enables you to filter and customize the search list based on available parameters in UserRequestBuilder. This feature allows you to keep uniformity between the displayed UserList and searched UserList.

Example In the example below, we are applying a filter to the UserList based on Search.

let usersRequestBuilder = UsersRequest.UsersRequestBuilder(limit: 20)
.set(searchKeyword: "**")

let usersWithMessages = CometChatUsers(usersRequestBuilder: usersRequestBuilder)
let naviVC = UINavigationController(rootViewController: usersWithMessages)
self.present(naviVC, animated: true)

Events

Events are emitted by a Component. By using event you can extend existing functionality. Being global events, they can be applied in Multiple Locations and are capable of being Added or Removed.

To handle events supported by Users you have to add corresponding listeners by using CometChatUserEvents

EventsDescription
emitOnUserBlockThis will get triggered when the logged in user blocks another user
emitOnUserUnblockThis will get triggered when the logged in user unblocks another user
///pass the [User] object of the user which has been blocked by the logged in user
CometChatUserEvents.emitOnUserBlock(user: User)

///pass the [User] object of the user which has been unblocked by the logged in user
CometChatUserEvents.emitOnUserUnblock(user: User)

Usage

Swift
// View controller from your project where you want to listen events.
public class ViewController: UIViewController {

public override func viewDidLoad() {
super.viewDidLoad()

// Subscribing for the listener to listen events from user module
CometChatUserEvents.addListener("UNIQUE_ID", self as CometChatUserEventListener)
}

public override func viewWillDisappear(_ animated: Bool) {
// Uncubscribing for the listener to listen events from user module
CometChatUserEvents.removeListener("LISTENER_ID_USED_FOR_ADDING_THIS_LISTENER")
}
}

// Listener events from user module
extension ViewController: CometChatUserEventListener {

func onUserBlock(user: User) {
// Do Stuff
}

func onUserUnblock(user: User) {
// Do Stuff
}
}

Customization

To fit your app's design requirements, you can customize the appearance of the users component. We provide exposed methods that allow you to modify the experience and behavior according to your specific needs.

Style

Using Style you can customize the look and feel of the component in your app, These parameters typically control elements such as the color, size, shape, and fonts used within the component.

1. Users Style

You can set the UsersStyle to the Users Component to customize the styling.

Global level styling

let customAvatarStyle = AvatarStyle()
customAvatarStyle.backgroundColor = UIColor(hex: "#FBAA75")
customAvatarStyle.cornerRadius = CometChatCornerStyle(cornerRadius: 20)

CometChatUsers.style.titleColor = UIColor(hex: "#F76808")
CometChatUsers.style.titleFont = UIFont(name: "Times-New-Roman", size: 34)
CometChatUsers.avatarStyle = customAvatarStyle

Instance level styling

let customAvatarStyle = AvatarStyle()
customAvatarStyle.backgroundColor = UIColor(hex: "#FBAA75")
customAvatarStyle.cornerRadius = CometChatCornerStyle(cornerRadius: 20)

let userStyle = UsersStyle()
userStyle.titleColor = UIColor(hex: "#F76808")
userStyle.titleFont = UIFont(name: "Times-New-Roman", size: 34)

let customUser = CometChatUsers()
customUser.style = userStyle
customUser.avatarStyle = customAvatarStyle
Image

List of properties exposed by MessageListStyle

PropertyDescriptionCode
List Item Selected ImageImage shown when a list item is selected.CometChatUsers.style.listItemSelectedImage = UIImage()
List Item Deselected ImageImage shown when a list item is deselected.CometChatUsers.style.listItemDeSelectedImage = UIImage()
Search Icon Tint ColorTint color for the search icon in the search bar.CometChatUsers.style.searchIconTintColor = UIColor()
Search Bar StyleStyle of the search bar (e.g., default, prominent).CometChatUsers.style.searchBarStyle = .default
Search Tint ColorTint color for the search bar elements.CometChatUsers.style.searchTintColor = UIColor?
Search Bar Tint ColorBackground color for the search bar (excluding text input).CometChatUsers.style.searchBarTintColor = UIColor?
Placeholder Text ColorColor of the placeholder text in the search bar.CometChatUsers.style.searchBarPlaceholderTextColor = UIColor?
Placeholder Text FontFont of the placeholder text in the search bar.CometChatUsers.style.searchBarPlaceholderTextFont = UIFont?
Search Bar Text ColorColor of the entered text in the search bar.CometChatUsers.style.searchBarTextColor = UIColor?
Search Bar Text FontFont of the entered text in the search bar.CometChatUsers.style.searchBarTextFont = UIFont?
Search Bar Background ColorBackground color of the search bar’s text input area.CometChatUsers.style.searchBarBackgroundColor = UIColor?
Cancel Icon Tint ColorTint color for the cancel button in the search bar.CometChatUsers.style.searchBarCancelIconTintColor = UIColor?
Cross Icon Tint ColorTint color for the clear (cross) button in the search bar.CometChatUsers.style.searchBarCrossIconTintColor = UIColor?
Background ColorBackground color for the entire screen or view..backgroundColor = CometChatTheme.backgroundColor01
Border WidthBorder width for the search bar or container.CometChatUsers.style.borderWidth = 0
Border ColorColor of the border, default is clear.CometChatUsers.style.borderColor = .clear
Corner RadiusCorner radius for search bar or other elements.CometChatUsers.style.cornerRadius = CometChatCornerStyle.init(cornerRadius: 0)
Title Text ColorText color for title elements within the list or navigation bar.CometChatUsers.style.titleColor = CometChatTheme.textColorPrimary
Title FontFont for title text.CometChatUsers.style.titleFont = CometChatTypography.Heading4.medium
Large Title Text ColorText color for large titles.CometChatUsers.style.largeTitleColor = CometChatTheme.textColorPrimary
Large Title FontFont for large titles.CometChatUsers.style.largeTitleFont = UIFont?
Navigation Bar Tint ColorTint color for the navigation bar background.CometChatUsers.style.navigationBarTintColor = CometChatTheme.backgroundColor01
Navigation Bar Items Tint ColorTint color for navigation bar items (buttons, icons).CometChatUsers.style.navigationBarItemsTintColor = CometChatTheme.iconColorHighlight
Error Title FontFont for the error title displayed in UI.CometChatUsers.style.errorTitleTextFont = CometChatTypography.Heading3.bold
Error Title Text ColorText color for the error title.CometChatUsers.style.errorTitleTextColor = CometChatTheme.textColorPrimary
Error Subtitle FontFont for the subtitle of error messages.CometChatUsers.style.errorSubTitleFont = CometChatTypography.Body.regular
Error Subtitle Text ColorText color for the subtitle of error messages.CometChatUsers.style.errorSubTitleTextColor = CometChatTheme.textColorSecondary
Retry Button Text ColorText color for the retry button in error states.CometChatUsers.style.retryButtonTextColor = CometChatTheme.buttonTextColor
Retry Button Text FontFont for the retry button text.CometChatUsers.style.retryButtonTextFont = CometChatTypography.Button.medium
Retry Button Background ColorBackground color for the retry button.CometChatUsers.style.retryButtonBackgroundColor = CometChatTheme.primaryColor
Retry Button Border ColorBorder color for the retry button.CometChatUsers.style.retryButtonBorderColor = .clear
Retry Button Border WidthBorder width for the retry button.CometChatUsers.style.retryButtonBorderWidth = 0
Retry Button Corner RadiusCorner radius for the retry button.CometChatUsers.style.retryButtonCornerRadius = CometChatCornerStyle?
Empty State Title FontFont for the empty state title (when no users/items are present).CometChatUsers.style.emptyTitleTextFont = CometChatTypography.Heading3.bold
Empty State Title ColorText color for the empty state title.CometChatUsers.style.emptyTitleTextColor = CometChatTheme.textColorPrimary
Empty Subtitle FontFont for the subtitle in the empty state.CometChatUsers.style.emptySubTitleFont = CometChatTypography.Body.regular
Empty Subtitle Text ColorText color for the subtitle in the empty state.CometChatUsers.style.emptySubTitleTextColor = CometChatTheme.textColorSecondary
Table View Separator ColorColor for the table view separator.CometChatUsers.style.tableViewSeparator = .clear
List Item Title Text ColorText color for list item titles.CometChatUsers.style.listItemTitleTextColor = CometChatTheme.textColorPrimary
List Item Title FontFont for list item titles.CometChatUsers.style.listItemTitleFont = CometChatTypography.Heading4.medium
List Item Subtitle Text ColorText color for list item subtitles.CometChatUsers.style.listItemSubTitleTextColor = CometChatTheme.textColorSecondary
List Item Subtitle FontFont for list item subtitles.CometChatUsers.style.listItemSubTitleFont = CometChatTypography.Body.regular
List Item BackgroundBackground color for individual list items.CometChatUsers.style.listItemBackground = .clear
List Item Border WidthBorder width for individual list items.CometChatUsers.style.listItemBorderWidth = 0
List Item Border ColorBorder color for individual list items.CometChatUsers.style.listItemBorderColor = CometChatTheme.borderColorLight
List Item Corner RadiusCorner radius for list items.CometChatUsers.style.listItemCornerRadius = CometChatCornerStyle.init(cornerRadius: 0)
Selection Image Tint ColorTint color for selection indicator in list items.CometChatUsers.style.listItemSelectionImageTint = CometChatTheme.iconColorHighlight
Selected Background ColorBackground color for selected list items.CometChatUsers.style.listItemSelectedBackground = .clear
Deselected Image Tint ColorTint color for the deselected state image.CometChatUsers.style.listItemDeSelectedImageTint = CometChatTheme.borderColorDefault
Header Title ColorText color for section header titles in the list.CometChatUsers.style.headerTitleColor = CometChatTheme.textColorHighlight
Header Title FontFont for section header titles.CometChatUsers.style.headerTitleFont = CometChatTypography.Heading4.medium

Functionality

These are a set of small functional customizations that allow you to fine-tune the overall experience of the component. With these, you can change text, set custom icons, and toggle the visibility of UI elements.

Below is a list of customizations along with corresponding code snippets

MethodDescriptionCode
set(userRequestBuilder:)Sets a custom request builder for fetching users..set(userRequestBuilder: UsersRequest.UsersRequestBuilder())
set(searchRequestBuilder:)Sets a custom request builder for searching users..set(searchRequestBuilder: UsersRequest.UsersRequestBuilder())
set(searchKeyword:)Sets a search keyword for filtering users..set(searchKeyword: "John")
hideErrorViewHides the error state view.hideErrorView = true
hideNavigationBarHides or shows the navigation bar.hideNavigationBar = true
hideSearchHides the search bar.hideSearch = true
hideBackButtonHides the back button.hideBackButton = true
hideLoadingStateHides the loading state indicator.hideLoadingState = true
hideUserStatusHides the online/offline status of users.hideUserStatus = true
hideSectionHeaderHides the section header for table view indicating initials of users.hideSectionHeader = true

Advance

For advanced-level customization, you can set custom views to the component. This lets you tailor each aspect of the component to fit your exact needs and application aesthetics. You can create and define your views, layouts, and UI elements and then incorporate those into the component.


SetOptions

You can define custom options for each user using .set(options:). This method allows you to return an array of CometChatUserOption based on the user object.

cometChatUsers.set(options: { user in  
return [CometChatUserOptions]
})

AddOptions

You can dynamically add options to users using .add(options:). This method lets you return additional CometChatUserOption elements.

cometChatUsers.add(options: { user in  
return [ArchiveOption()]
})

SetListItemView

With this function, you can assign a custom ListItem to the users Component.

let cometChatUser = CometChatUsers()
cometChatUser.set(listItemView: { user in
//Perform Your Actions
})
Image

You can indeed create a custom listitem UIView file named Custom_User_ListItem_View for more complex or unique list items.

Afterwards, seamlessly integrate this Custom_User_ListItem_View UIView file into the .setListItemView method within CometChatUsers().

You can create a CustomListItemView as a custom UIView. Which we will inflate in setListItemView()

swift

import UIKit
import CometChatUIKitSwift

class CustomListItem: UIView {
// Initialize UI components
private var profileImageView: CometChatAvatar = {
let imageView = CometChatAvatar(image: UIImage())
imageView.translatesAutoresizingMaskIntoConstraints = false // Important for manual layout
return imageView
}()

private var nameLabel: UILabel = {
let label = UILabel()
label.translatesAutoresizingMaskIntoConstraints = false // Important for manual layout
return label
}()

override init(frame: CGRect) {
super.init(frame: frame)
setupUI()
}

required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

private func setupUI() {
addSubview(profileImageView)
addSubview(nameLabel)

NSLayoutConstraint.activate([
// Profile image constraints
profileImageView.leadingAnchor.constraint(equalTo: leadingAnchor, constant: 8),
profileImageView.centerYAnchor.constraint(equalTo: centerYAnchor),
profileImageView.widthAnchor.constraint(equalToConstant: 40),
profileImageView.heightAnchor.constraint(equalToConstant: 40),

nameLabel.leadingAnchor.constraint(equalTo: profileImageView.trailingAnchor, constant: 8),
nameLabel.trailingAnchor.constraint(equalTo: trailingAnchor, constant: -8),
nameLabel.centerYAnchor.constraint(equalTo: centerYAnchor)
])
}

func set(user: User) {
var avatarURL: String?
if let group = conversation.conversationWith as? Group {
nameLabel.text = group.name
avatarURL = group.icon
}

if let user = conversation.conversationWith as? User {
nameLabel.text = user.name
avatarURL = user.avatar
}




self.profileImageView.setAvatar(avatarUrl: avatarURL, with: nameLabel.text)
}
}

SetLeadingView

You can modify the leading view of a user cell using .set(leadingView:).

cometChatUsers.set(leadingView: { user in  
let view = CustomLeadingView()
return view
})

Demonstration

Image

You can create a CustomLeadingView as a custom UIView. Which we will inflate in setLeadingView()

import UIKit

class CustomLeadingView: UIView {

private let imageView: UIImageView = {
let imageView = UIImageView()
imageView.contentMode = .scaleAspectFill
imageView.clipsToBounds = true
imageView.layer.cornerRadius = 10
return imageView
}()

private let badgeView: UIView = {
let view = UIView()
view.backgroundColor = .orange
view.layer.cornerRadius = 12
view.layer.borderWidth = 2
view.layer.borderColor = UIColor.white.cgColor

let icon = UIImageView(image: UIImage(systemName: "star.fill"))
icon.tintColor = .white
icon.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(icon)

NSLayoutConstraint.activate([
icon.centerXAnchor.constraint(equalTo: view.centerXAnchor),
icon.centerYAnchor.constraint(equalTo: view.centerYAnchor),
icon.widthAnchor.constraint(equalToConstant: 14),
icon.heightAnchor.constraint(equalToConstant: 14)
])

return view
}()

init(image: UIImage?) {
super.init(frame: .zero)
imageView.image = image

addSubview(imageView)
addSubview(badgeView)

imageView.translatesAutoresizingMaskIntoConstraints = false
badgeView.translatesAutoresizingMaskIntoConstraints = false

NSLayoutConstraint.activate([
imageView.topAnchor.constraint(equalTo: topAnchor),
imageView.leadingAnchor.constraint(equalTo: leadingAnchor),
imageView.trailingAnchor.constraint(equalTo: trailingAnchor),
imageView.bottomAnchor.constraint(equalTo: bottomAnchor),

badgeView.widthAnchor.constraint(equalToConstant: 24),
badgeView.heightAnchor.constraint(equalToConstant: 24),
badgeView.bottomAnchor.constraint(equalTo: imageView.bottomAnchor, constant: -4),
badgeView.trailingAnchor.constraint(equalTo: imageView.trailingAnchor, constant: -4)
])
}

required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}



SetTitleView

You can customize the title view of a user cell using .set(titleView:).

cometChatUsers.set(titleView: { user in  
let view = CustomTitleView()
return view
})

Demonstration

Image

You can create a CustomTitleView as a custom UIView. Which we will inflate in setTitleView()

import UIKit

class CustomTitleView: UIView {

private let nameLabel: UILabel = {
let label = UILabel()
label.font = UIFont.boldSystemFont(ofSize: 18)
label.textColor = .black
return label
}()

private let badgeLabel: UILabel = {
let label = UILabel()
label.font = UIFont.systemFont(ofSize: 14)
label.textColor = .white
label.backgroundColor = .systemGreen
label.text = "Teacher"
label.textAlignment = .center
label.layer.cornerRadius = 8
label.layer.masksToBounds = true
return label
}()

init(name: String, role: String) {
super.init(frame: .zero)
nameLabel.text = name
badgeLabel.text = " \(role) "

let stackView = UIStackView(arrangedSubviews: [nameLabel, badgeLabel])
stackView.axis = .horizontal
stackView.spacing = 8
stackView.alignment = .center

addSubview(stackView)
stackView.translatesAutoresizingMaskIntoConstraints = false

NSLayoutConstraint.activate([
stackView.leadingAnchor.constraint(equalTo: leadingAnchor),
stackView.trailingAnchor.constraint(equalTo: trailingAnchor),
stackView.topAnchor.constraint(equalTo: topAnchor),
stackView.bottomAnchor.constraint(equalTo: bottomAnchor)
])
}

required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}



SetTrailView

You can modify the trailing view of a user cell using .set(trailView:).

cometChatUsers.set(trailView: { user in  
let view = CustomTrailView()
return view
})

Demonstration

Image

You can create a CustomTrailView as a custom UIView. Which we will inflate in setTrailView()

import UIKit

class CustomTrailView: UIView {

private let badgeView: UIView = {
let view = UIView()
view.backgroundColor = .purple
view.layer.cornerRadius = 12
view.translatesAutoresizingMaskIntoConstraints = false
return view
}()

private let icon: UIImageView = {
let imageView = UIImageView(image: UIImage(systemName: "star.fill"))
imageView.tintColor = .white
imageView.translatesAutoresizingMaskIntoConstraints = false
return imageView
}()

private let label: UILabel = {
let label = UILabel()
label.text = "PRO"
label.font = UIFont.boldSystemFont(ofSize: 14)
label.textColor = .white
label.translatesAutoresizingMaskIntoConstraints = false
return label
}()

init() {
super.init(frame: .zero)

addSubview(badgeView)
badgeView.addSubview(icon)
badgeView.addSubview(label)

NSLayoutConstraint.activate([
badgeView.leadingAnchor.constraint(equalTo: leadingAnchor),
badgeView.trailingAnchor.constraint(equalTo: trailingAnchor),
badgeView.topAnchor.constraint(equalTo: topAnchor),
badgeView.bottomAnchor.constraint(equalTo: bottomAnchor),

icon.centerXAnchor.constraint(equalTo: badgeView.centerXAnchor),
icon.topAnchor.constraint(equalTo: badgeView.topAnchor, constant: 4),
icon.widthAnchor.constraint(equalToConstant: 16),
icon.heightAnchor.constraint(equalToConstant: 16),

label.centerXAnchor.constraint(equalTo: badgeView.centerXAnchor),
label.topAnchor.constraint(equalTo: icon.bottomAnchor, constant: 2),
label.bottomAnchor.constraint(equalTo: badgeView.bottomAnchor, constant: -4)
])
}

required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}



SetSubTitleView

You can customize the subtitle view for each users item to meet your requirements

let cometChatUser = CometChatUsers()
cometChatUser.set(subtitleView: { user in
let view = CustomSubtitleView()
return view
})

Example

Demonstration

Image

You can seamlessly integrate this CustomSubtitleView UIView file into the .set(subtitleView:) method within CometChatUsers.

import UIKit

class CustomSubtitleView: UILabel {

init(lastActiveDate: String) {
super.init(frame: .zero)
self.text = "Last Active at: \(lastActiveDate)"
self.textColor = UIColor.gray
self.font = UIFont.systemFont(ofSize: 14)
self.numberOfLines = 1
}

required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}


SetLoadingView

You can set a custom loading view using .set(loadingView:). This method accepts a UIView to display while data is being fetched.

let loadingIndicator = UIActivityIndicatorView(style: .medium)  
loadingIndicator.startAnimating()
cometChatUsers.set(loadingView: loadingIndicator)

SetErrorView

You can customize the error view using .set(errorView:). This method accepts a UIView that appears when an error occurs.

let errorLabel = UILabel()  
errorLabel.text = "Something went wrong!"
errorLabel.textColor = .red
cometChatUsers.set(errorView: errorLabel)

SetEmptyView

You can customize the empty state view using .set(emptyView:). This method accepts a UIView that appears when no user are available.

let emptyLabel = UILabel()  
emptyLabel.text = "No users found"
emptyLabel.textColor = .gray
emptyLabel.textAlignment = .center
cometChatUsers.set(emptyView: emptyLabel)