Skip to main content

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)
During the initialization of CometChatConversations, users can provide this custom request builder.
Swift
If a navigation controller is already in use, opt for the pushViewController method 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.
  1. 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.

2. setOnBack
This setOnBack method becomes valuable when a user needs to override the action triggered upon pressing the back button in CometChatConversations.

3. setOnSelection
The selectionMode 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.

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

Filters

You can set ConversationsRequestBuilder 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.
  1. Conversation Type: Filters on type of Conversation, User or Groups
  2. Limit: Number of conversations fetched in a single request.
  3. WithTags: Filter on fetching conversations containing tags
  4. Tags: Filters on specific Tag
  5. UserTags: Filters on specific User Tag
  6. GroupTags: Filters on specific Group Tag
If a navigation controller is already in use, opt for the pushViewController method instead of presenting the view controller.

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.
1. ConversationDeleted
This event will be emitted when the user deletes a conversation
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 the ConversationsStyle to the Conversations Component to customize the styling.
List of properties exposed by ConversationStyle
2. Avatar Style
To apply customized styles to the Avatar component in the Conversations Component, you can use the following code snippet. For more information, visit Avatar Styles.
3. StatusIndicator Style
To apply customized styles to the Status Indicator component in the Conversations Component, you can use the following code snippet. For more information, visit Indicator Styles.
4. Date Style
To apply customized styles to the Date component in the Conversations Component, you can use the following code snippet. For more information, visit Date Styles.
5. Badge Style
To apply customized styles to the Badge component in the Conversations Component, you can use the following code snippet. For more information, visit Badge Styles
6. LisItem Style
To apply customized styles to the ListItemStyle component in the Conversations Component, you can use the following code snippet. For more information, visit List Item Styles.

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

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.
Demonstration
You can create a 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).
Swift

SetMenu

You can set the Custom Menu view to add more options to the Conversations component.
Demonstration
You can create a new array of [UIBarButtonItem]( ) objects. This array will be inflated and then passed to the .setMenu.
Swift
You can manage click actions accordingly.

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.
Demonstration

SetSubtitleView

You can customize the subtitle view for each conversation item to meet your requirements
Demonstration
You need to create a 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.
  • SubtitleView file should should appear as follows:
Swift

SetErrorStateView

You can set a custom ErrorStateView using setEmptyStateView to match the error view of your app.
Demonstration We have added an error view to errorView. You can choose any view you prefer. This view should be inflated and passed to the setErrorView() method.
Swift
Swift