Overview
The Messages is a Composite Component that manages messages for users and groups. The Messages component is composed of three individual components, MessageHeader, MessageList, and MessageComposer. In addition, the Messages component also navigates to the Details and ThreadedMessages components.
CometChatMessages mainly contains below components in it.
| Components | Description |
|---|---|
| MessageHeader | CometChatMessageHeader displays the User or Group information using CometChat SDK’s User or Group object. It also shows the typing indicator when the user starts typing in MessageComposer. |
| MessageList | CometChatMessageList is one of the core UI components. It displays a list of messages and handles real-time operations. |
| MessageComposer | CometChatMessageComposer is an independent and critical component that allows users to compose and send various types of messages includes text, image, video and custom messages. |
| Details | CometChatDetails is a component that displays all the available options available for Users & Groups |
| ThreadedMessages | CometChatThreadedMessages is a component that displays all replies made to a particular message in a conversation. |
Usage
Integration
The following code snippet illustrates how you can can launch CometChatMessages.- For User
- For Group
If you are already using a navigation controller, you can use the
pushViewController function instead of presenting the 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. The Messages component does not have its actions. However, since it’s a Composite Component, you can use the actions of its components by utilizing the Configurations object of each component. Example In this example, we are employing the ThreadRepliesClick action from the MessageList Component through the MessageListConfiguration object.- Swift

The Messages Component overrides the ThreadRepliesClick action to navigate to the ThreadedMessages component. If you override ThreadRepliesClick, it will also override the default behavior of the Messages Component.
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. The Messages component does not have its filters. But as it is a Composite Component, you can use the filters of its components by using the Configurations object of each component. For more details on the filters of its components, please refer to MessageList Filters. Example In this example, we’re applying the MessageList Component filter to the Messages Component usingMessageListConfiguration.
- Swift
Events
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 list of events emitted by the Messages component is as follows.
| Event | Description |
|---|---|
| onMessageSent | Triggers whenever a loggedIn user sends any message, it will have two states such as: inProgress & sent |
| onMessageEdit | Triggers whenever a loggedIn user edits any message from the list of messages .it will have two states such as: inProgress & sent |
| onMessageDelete | Triggers whenever a loggedIn user deletes any message from the list of messages |
| onMessageRead | Triggers whenever a loggedIn user reads any message. |
| onLiveReaction | Triggers whenever a loggedIn clicks on live reaction |
CometChatMessageEvents Listener’s
- Swift
CometChatMessageEvents Listener’s
- Swift
Customization
To fit your app’s design requirements, you can customize the appearance of the conversation 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.-
Messages Style
- Swift
| Property | Description | Code |
|---|---|---|
| set Background | Used to set the background color | .set(background: UIColor) |
| set BorderColor | Used to set border color | .set(borderColor: UIColor) |
| set BorderWidth | Used to set border width | .set(borderWidth: CGFloat) |
| set CornerRadius | Used to set corner radius | .set(cornerRadius: CometChatCornerStyle) |
2. Component’s Styles
Being a Composite component, the Messages Component allows you to customize the styles of its components using their respective Configuration objects. For a list of all available properties, refer to each component’s styling documentation: MesssageHeader Styles, MessageList Styles, MessageComposer Styles, Details Styles, ThreadMessages Styles. Example In this example, we are creatingMessageListStyle and MessageComposerStyle and then applying them to the Messages Component using MessageListConfiguration and MessageComposerConfiguration.
- 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.- Swift
If you are already using a navigation controller, you can use the pushViewController function instead of presenting the view controller.
| Property | Description | Code |
|---|---|---|
| User | Used to pass user object of which header specific details will be shown | .set(user: User) |
| Group | Used to pass group object of which header specific details will be shown | .set(group: Group) |
| Hide MessageComposer | Used to toggle visibility for CometChatMessageComposer, default false | .hide(messageComposer: Bool) |
| Hide MessageHeader | Used to toggle visibility for CometChatMessageHeader, default false | .hide(messageHeader: Bool) |
| Disable Typing | Used to toggle functionality for showing typing indicator and also enable/disable sending message delivery/read receipts | .disable(disableTyping: Bool) |
| Disable SoundForMessages | Used to toggle sound for messages | .disable(soundForMessages: Bool) |
| Set CustomSoundForIncomingMessages | Used to set custom sound asset’s path for incoming messages | .set(customSoundForIncomingMessages: URL) |
| Set CustomSoundForOutgoingMessages | Used to set custom sound asset’s path for outgoing messages | .set(customSoundForOutgoingMessages: URL) |
| Hide Details | Used to toggle visibility for details icon in CometChatMessageHeader | .hide(details: Bool) |
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 views, layouts, and UI elements and then incorporate those into the component.MessageHeaderView
You can set your custom message header view using thesetMessageHeaderView() method. But keep in mind, by using this you will override the default message header functionality.
- Swift

custom_header_view and pass it inside the setMessageHeaderView() method.
custom_header_view
- Swift
Ensure to pass and present
cometChatMessages. If a navigation controller is already in use, utilize the pushViewController function instead of directly presenting the view controller.SetMessageComposerView
You can set your custom Message Composer view using thesetMessageComposerView() method. But keep in mind, by using this you will override the default message composer functionality.
- Swift
- Utilized for configuring a custom message composer.

custom_composer_style while creating a MessageComposerStyle object.
Swift
Ensure to pass and present
cometChatMessages. If a navigation controller is already in use, utilize the pushViewController function instead of directly presenting the view controller.- Swift
Ensure to pass your own
CustomMessageComposer view.SetAuxiliaryHeaderMenu
This will configure the auxiliary menu options displayed in the CometChatMessageHeader within CometChatMessages by using thesetAuxiliaryMenu() method. Users can specify different auxiliary menu options that appear before the details option.
- Swift
Details options which is by default visible on CometChatHeader will not be altered by this option.> > If you want to hide detail use setHideDetail properties instead

.setAuxiliaryMenu()
setAuxiliaryMenu() method to establish its default functionality. By setting an Auxiliary Menu, the Messages Component gains the capability to navigate to the Details section.
Configuration
Configurations offer the ability to customize the properties of each individual component within a Composite Component. The Messages Component is a Composite Component and it has a specific set of configuration for each of its components.MessageHeader report
If you want to customize the properties of the MessageHeader Component inside Messages Component, you need use theMessageHeaderConfiguration object.
- Swift
MessageHeaderConfiguration provides access to all the Action, Filters, Styles, Functionality, and Advanced properties of the MessageHeader component.
Please note that the Properties marked with the symbol are not accessible within the Configuration Object.Example In this example, we will be adding a custom back button and styling a few properties of the Avatar component of the MessageHeader component using
MessageHeaderConfiguration.
- Swift
MessageList
If you want to customize the properties of the MessageList Component inside Messages Component, you need use theMessageListConfiguration object.
- Swift
MessageListConfiguration provides access to all the Action, Filters, Styles, Functionality, and Advanced properties of the MessageList component.
Please note that the Properties marked with the symbol are not accessible within the Configuration Object.Example

MessageListConfiguration.
- Swift
Ensure to pass and present
cometChatMessages. If a navigation controller is already in use, utilize the pushViewController function instead of directly presenting the view controller.MessageComposer
If you want to customize the properties of the MessageComposer Component inside Messages Component, you need use theMessageComposerConfiguration object.
- Swift
MessageComposerConfiguration provides access to all the Action, Filters, Styles, Functionality, and Advanced properties of the MessageComposer component.
Please note that the Properties marked with the symbol are not accessible within the Configuration Object.Example

MessageComposerConfiguration.
- Swift
Ensure to pass and present
cometChatMessages. If a navigation controller is already in use, utilize the pushViewController function instead of directly presenting the view controller.ThreadedMessages report
If you want to customize the properties of the ThreadedMessages Component inside Messages Component, you need use theThreadedMessagesConfiguration object.
- Swift
ThreadedMessagesConfiguration provides access to all the Action, Filters, Styles, Functionality, and Advanced properties of the ThreadedMessages component.
Please note that the Properties marked with the symbol are not accessible within the Configuration Object.Example

MessageListConfiguration. We then apply these changes to the ThreadedMessages component using ThreadedMessagesConfiguration.
- Swift
Ensure to pass and present
cometChatMessages. If a navigation controller is already in use, utilize the pushViewController function instead of directly presenting the view controller.