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. Features such as Live Reaction, Attachments, and Message Editing are also supported by it.
Image
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 app.

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. onSendButtonPress
The onSendButtonPress event gets activated when the send message button is clicked. It has a predefined function of sending messages entered in the composer EditText. However, you can overide this action with the following code snippet.
2. onError
This action doesn’t change the behavior of the component but rather listens for any errors that occur in the MessageList component.

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 list of events emitted by the Messages component is as follows. Adding CometChatMessageEvents Listener’s

Removing CometChatMessageEvents Listener’s

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 modify the styling, you can apply the MessageComposerStyle to the MessageComposer Component using the messageComposerStyle property.
The following properties are exposed by MessageComposerStyle:
2. MediaRecorder Style
To customize the styles of the MediaRecorder component within the MessageComposer Component, use the mediaRecorderStyle property. For more details, please refer to MediaRecorder 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.
Image
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.

AttachmentOptions

By using attachmentOptions, you can set a list of custom MessageComposerActions for the MessageComposer Component. This will override the existing list of MessageComposerActions. Example
Image

AuxiliaryButtonView

You can insert a custom view into the MessageComposer component to add additional functionality using the following method. Please note that the MessageComposer Component utilizes the AuxiliaryButton to provide sticker functionality. Overriding the AuxiliaryButton will subsequently replace the sticker functionality. In this example, we’ll be adding a custom SOS button. Example
Image

SecondaryButtonView

You can add a custom view into the SecondaryButton component for additional functionality using the below method. In this example, we’ll be adding a custom SOS button. Example
Image

SendButtonView

You can set a custom view in place of the already existing send button view. Using the following method. Example
Image

HeaderView

You can set custom HeaderView to the MessageComposer component using the following method In the following example, we’re going to apply a mock chat bot button to the MessageComposer Component using the HeaderView property. Example
Image

TextFormatters

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