Overview
CometChatUsersWithMessages is a Composite Component that seamlessly merges the functionalities of both the Users and Messages modules. It empowers users to effortlessly navigate to any individual’s chat window by simply clicking on their respective list item in the user list.
Additionally, CometChatUsersWithMessages inherits and encompasses all attributes available within the CometChatUsers module, ensuring a comprehensive user experience.

| Components | Description |
|---|---|
| Users | Users serves as a standalone component designed to establish a screen displaying a list of users, providing them with the capability to search for specific individuals. This component operates as a container, inheriting from CometChatListBase, and serves as a wrapper for the CometChatUserList component. |
| Messages | Messages presents the chat interface for both individual users and group entities. It exhibits a message list containing all interactions where the loggedInUser has sent or received messages from any of these entities. |
Usage
Integration
SinceCometChatUsersWithMessages is a view controller, it can be launched either by a button click or through any event’s trigger. It inherits all the customizable properties and methods of CometChatUsers.
View Controller: To use CometChatUsersWithMessages in your view controller, use the following code snippet.
view controller
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. SetOnItemClick
ThesetOnItemClick method is used to override the onClick behavior in CometChatUsersWithMessages. By default, this action has a predefined behavior which navigates to the messages. However, you have the flexibility to override this event and tailor it to suit your needs using the following code snippet.
- Swift
2. SetOnItemLongClick
This methodsetOnItemLongClick, empowers users to customize long-click actions within CometChatUsersWithMessages, offering enhanced functionality and interaction possibilities.
- Swift
3. SetOnBack
This method allows users to override the onBack Pressed behavior in CometChatUsersWithMessages by utilizing thesetOnBack , providing customization options for handling the back action.
By default, this action has a predefined behavior: it simply dismisses the current view controller. However, the flexibility of CometChat UI Kit allows you to override this standard behavior according to your application’s specific requirements. You can define a custom action that will be performed instead when the back button is pressed.
- Swift
4. onError
This methodsetOnError, allows users to override error handling within CometChatUsersWithMessages, providing greater control over error responses and actions.
- Swift
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. While the UsersWithMessages component does not have filters, its components do, For more detail on individual filters of its component refer to Users FiltersMessages Filters By utilizing the Configurations object of its components, you can apply filters. In the following example, we’re sortingUsers by UID's and setting the limit to 10 using the usersRequestBuilder.
- Swift
make sure to
import CometChatSDKEvents
Events are emitted by aComponent. 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.
The UsersWithMessages does not produce any events but its component does.
Customization
To fit your app’s design requirements, you have the ability to customize the appearance of the UsersWithMessages 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. UsersWithMessages Style 🛑
You can set theUsersWithMessagesStyle to the UsersWithMessages Component to customize the styling.
Example
- Swift
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. UsersWithMessages component does not have any available functionality.Advanced
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 own views, layouts, and UI elements and then incorporate those into the component. By utilizing the Configuration object of each component, you can apply advanced-level customizations to theUsersWithMessages.
Example
CometChatUsersWithMessages component and configure it with a UsersConfiguration object. This ensures seamless integration and optimal functionality within your application.
- UsersWithMessages utilizes the SetMenu function of the
Userssubcomponent to navigate the User to Messages

- UsersWithMessages utilizes the SetMenu function of the
Messagessubcomponent to navigatefrom Messages to Details.

When you override
.setMenu(), the default behavior of UsersWithMessages will also be overridden.Configurations
Configurations offer the ability to customize the properties of each component within a Composite Component. UsersWithMessages hasUsers and Messages component. Hence, each of these components will have its individual `Configuration“.
Configurationsexpose properties that are available in its individual components.
Users
You can customize the properties of the Users component by making use of the UsersConfiguration. You can accomplish this by employing the.set(usersConfiguration: usersConfiguration) method as demonstrated below:
- Swift
CometChatUsersWithMessages as a child component. To configure CometChatUsersWithMessages, simply provide the usersConfiguration object using the .set(usersConfiguration:) method. This facilitates seamless customization and integration of user-specific settings within the CometChatUsersWithMessages component.
UsersConfiguration can be found under Users. Properties marked with the symbol are not accessible within the Configuration Object.
Example
Let’s say you want to change the style of the Users subcomponent and, in addition, you only want to display users with offline status.
You can modify the style using the UsersStyle method and filter the list with the UsersRequestBuilder method.

- Swift
make sure to
import CometChatSDKMessages
You can customize the properties of the Messages component by making use of themessagesConfiguration. You can accomplish this by employing the messagesConfiguration as demonstrated below:
- Swift
MessagesConfiguration can be found under Messages. Properties marked with the symbol are not accessible within the Configuration Object.
Example
Let’s say you want to change the style of the Messages subcomponent and, in addition, you want to hide message composer.
You can modify the style using the messagesStyle method and hide using hide(messageComposer: bool) method.

- Swift