Overview
The Conversations is a Component, That shows all conversations related to the currently logged-in user,
Usage
Integration
As CometChatConversations is a custom view controller, it can be initiated either by tapping a button or through the trigger of any event. It offers multiple parameters and methods for tailoring its user interface.swift
- Integration (With Custom Request Builder)
swift
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.-
set(onItemClick:)
set(OnItemClick:) is triggered when you click on a ListItem of the Conversations component. This set(OnItemClick:) method proves beneficial when a user intends to customize the on-click behavior in CometChatConversations.
- Swift
-
set(OnItemLongClick:)
set(OnItemLongClick:) is triggered when you long press on a ListItem of the Conversations component. This set(OnItemLongClick:) method proves beneficial when a user intends to additional functionality on long press on list item in CometChatConversations.
- Swift
3. set(onBack:)
Thisset(onBack:) method becomes valuable when a user needs to override the action triggered upon pressing the back button in CometChatConversations.
- Swift
4. set(onSelection:)
Theset(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 conversations.
- Swift
5. set(onError:)
This method proves helpful when a user needs to customize the action taken upon encountering an error in CometChatConversations.- Swift
6. set(onEmpty:)
Thisset(onEmpty:) method is triggered when the conversations list is empty in CometChatConversations.
- Swift
7. setOnLoad
This set(onLoad:) gets triggered when a conversation list is fully fetched and going to displayed on the screen, this return the list of conversations to get displayed on the screen.- Swift
Filters
You can setConversationsRequestBuilder in the Conversations Component to filter the conversation list. You can modify the builder as per your specific requirements with multiple options available to know more refer to ConversationRequestBuilder.
You can set filters using the following parameters.
- Conversation Type: Filters on type of Conversation,
UserorGroups - Limit: Number of conversations fetched in a single request.
- WithTags: Filter on fetching conversations containing tags
- Tags: Filters on specific
Tag - UserTags: Filters on specific User
Tag - GroupTags: Filters on specific Group
Tag
- 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.
1. ConversationDeleted
This event will be emitted when the user deletes a conversation- Swift
Add Listener
Remove Listener
Customization
To align with your app’s design specifications, you have the flexibility to customize the appearance of the conversation component. We offer accessible methods that empower you to tailor the experience and functionality to meet your unique requirements.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. Conversation Style
The CometChatConversation component allows developers to customize its appearance through the ConversationStyle class. This enables global-level or instance-specific styling. Global level styling- Swift
- Swift

2. Avatar Style
To apply customized styles to theAvatar component in the Conversations Component, you can use the following code snippet. For more information, visit Avatar Styles.
Global level styling
- Swift
- Swift

3. StatusIndicator Style
To apply customized styles to the Status Indicator component in theConversations Component, you can use the following code snippet. For more information, visit Indicator Styles.
Global level styling
- Swift
- Swift

4. Badge Style
To apply customized styles to theBadge component in the Conversations Component, you can use the following code snippet. For more information, visit Badge Styles
Global level styling
- Swift
- 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. Below is a list of customizations along with corresponding code snippetsAdvanced
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.Date Time Formatter
The CometChatConversations component supports full customization of how date and time are displayed using the CometChatDateTimeFormatter. This enables developers to localize, format, or personalize the date and time strings shown next to each conversation—such as “Today”, “Yesterday”, “12:45 PM”, etc.- Component-Level (Global)
- Swift
- Instance-Level (Local)
- Swift
Available closures
Each closure receives a timestamp (Int, representing UNIX time) and must return a String representing the formatted time.
SetTextFormatters
You can modify the text formatters by using .set(textFormatters:). This method accepts an array of CometChatTextFormatter, allowing you to apply multiple text formatters to the conversation text.- Swift
cometChatConversations.set(textFormatters: [CometChatTextFormatter])
SetDatePattern
You can modify the date pattern to your requirement using .set(datePattern:). This method accepts a function with a return type String. Inside the function, you can create your own pattern and return it as a String.- Swift

SetOptions
You can define custom options for each conversation using .set(options:). This method allows you to return an array of CometChatConversationOption based on the conversation object.- Swift
AddOptions
You can dynamically add options to conversations using .add(options:). This method lets you return additional CometChatConversationOption elements.- Swift
SetCustomSoundForMessages
You can customize the notification sound for incoming messages using .set(customSoundForMessages:). This method accepts a URL pointing to the audio file.- Swift
SetListItemView
With this function, you can assign a custom ListItem view to the Conversations Component.- Swift

CustomListItemView as a custom UIView. Which we will inflate in setListItemView()
swift
SetLeadingView
You can modify the leading view of a conversation cell using .set(leadingView:).- Swift

CustomLeadingView as a custom UIView. Which we will inflate in setLeadingView()
- Swift
SetTitleView
You can customize the title view of a conversation cell using .set(titleView:).- Swift

CustomTitleView as a custom UIView. Which we will inflate in setTitleView()
- Swift
SetTrailView
You can modify the trailing view of a conversation cell using .set(trailView:).- Swift

CustomTrailView as a custom UIView. Which we will inflate in setTrailView()
- Swift
SetSubtitleView
You can customize the subtitle view for each conversation item to meet your requirements- Swift

SubtitleView a custom UIView cocoa touch file and inflate it in the setSubtitleView apply function. Then, you can define individual actions depending on your requirements.
SubtitleViewfile should should appear as follows:
swift
SetLoadingView
You can set a custom loading view using .set(loadingView:). This method accepts a UIView to display while data is being fetched.- Swift
SetErrorView
You can customize the error view using .set(errorView:). This method accepts a UIView that appears when an error occurs.- Swift
SetEmptyView
You can customize the empty state view using .set(emptyView:). This method accepts a UIView that appears when no conversations are available.- Swift