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.-
setOnItemClick
setOnItemClick is triggered when you click on a ListItem of the Conversations component. This setOnItemClick method proves beneficial when a user intends to customize the on-click behavior in CometChatConversations.
- Swift
2. setOnBack
ThissetOnBack method becomes valuable when a user needs to override the action triggered upon pressing the back button in CometChatConversations.
- Swift
3. setOnSelection
TheselectionMode feature enables selection with modes: .single and .multiple.
The setOnSelection event is triggered upon the completion of a selection in SelectionMode. This returns the selected conversations list when the callback is triggered. It can be executed with any button or action.
- Swift
4. setOnError
This method proves helpful when a user needs to customize the action taken upon encountering an error in CometChatConversations.- 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
You can set theConversationsStyle to the Conversations Component to customize the styling.
- 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.
- 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.
- Swift
4. Date Style
To apply customized styles to theDate component in the Conversations Component, you can use the following code snippet. For more information, visit Date Styles.
- Swift
5. 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
- Swift
6. LisItem Style
To apply customized styles to theListItemStyle component in the Conversations Component, you can use the following code snippet. For more information, visit List Item Styles.
- 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
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.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
SetTextFormatters
Assigns the list of text formatters. If the provided list is not null, it sets the list. Otherwise, it assigns the default text formatters retrieved from the data source. To configure the existing Mentions look and feel check out CometChatMentionsFormatter Example In this example, we demonstrate the creation of a custom Swift file for the CometChat text formatter. Here are the functions provided by the custom text formatter:- getRegex(): Defines words to replace, such as “hello”.
- getTrackingCharacter(): Initiates mention suggestions with ”@”.
- prepareMessageString( ): Formats specific words like “hello” based on message type (sent or received).

- Custom_text_formatter
Swift
SetMenu
You can set the Custom Menu view to add more options to the Conversations component.- Swift

[UIBarButtonItem]( ) objects. This array will be inflated and then passed to the .setMenu.
Swift
- Swift
SetDatePattern
You can modify the date pattern to your requirement using .setDatePattern. 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

- 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.
- Swift
SubtitleViewfile should should appear as follows:
Swift
SetErrorStateView
You can set a customErrorStateView using setEmptyStateView to match the error view of your app.
- Swift
errorView. You can choose any view you prefer. This view should be inflated and passed to the setErrorView() method.
Swift
- Swift
Swift