Skip to main content

Overview

MessageComposer is a Component that enables users to write and send a variety of messages, including text, image, video, and custom messages.
MessageComposer is comprised of the following Base Components:

Usage

Integration

The following code snippet illustrates how you can directly incorporate the MessageComposer component into your file.

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. onSendButtonClick
The set(onSendButtonClick:) event gets activated when the send message button is clicked. The following code snippet Overrides the action of the send button in CometChatMessageComposer.

2. OnTextChanged:
The set(onTextChanged:) event gets activated when the user starts typing in message composer. This will return the text entered by the user.

3. SetOnError
This method proves helpful when a user needs to customize the action taken upon encountering an error in CometChatMessageComposer.

Filters

MessageComposer component does not have any available filters.

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. The MessageComposer Component does not emit any events of its own.

Customization

To fit your app’s design requirements, you can customize the appearance of the MessageComposer 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. MessageComposer Style
To customize the styling, you can apply the MessageComposerStyle to the MessageComposer component. Global level styling
Instance level styling
The following properties are exposed by MessageComposerStyle:
2. MediaRecorder Style
To customize the media recording styling, you can apply the MediaRecorderStyle to the MessageComposer component. For more details, please refer to MediaRecorder styles. Global level styling
Instance level styling
The following properties are exposed by Media Recorder Style:
3. AI Options Style
To customize the media recording styling, you can apply the AIOptionsStyle to the MessageComposer component. For more details, please refer to MediaRecorder styles. Global level styling
Instance level styling
The following properties are exposed by AI Options Style:

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 set maximum lines text area will show before scrolling in the composer, edit a message, add header view and footer view to the composer, etc. Below is a list of customizations along with corresponding code snippets message composer offers

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.

AttachmentOptions

By using set(attachmentOptions:), you can set a list of custom MessageComposerActions for the MessageComposer Component. This will override the existing list of CometChatMessageComposerAction.
Demonstration
In this example, we are overriding the existing MessageComposerActions List with Capture Photo actions.

SendButtonView

By using set(sendButtonView:), you can set a custom send button for the MessageComposer Component.
Demonstration

HeaderView

By using set(headerView:), you can set a custom header view for the MessageComposer Component.
Demonstration

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

To ensure that the MessageComposer is properly configured, passing the controller is mandatory.
  • 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.