Skip to main content
CometChat supports three types of messages:

Text Message

Send a text message using CometChat.sendMessage() with a TextMessage object.
The TextMessage class constructor takes the following parameters: On success, sendMessage() returns a TextMessage | MediaMessage | CustomMessage | BaseMessage object containing all information related to the sent message.

Media Message

Send images, videos, audio, or files using CometChat.sendMediaMessage(). There are two ways to send media messages:
  1. Upload a file — Pass a file object and CometChat uploads it automatically
  2. Send a URL — Provide a URL to media hosted on your server or cloud storage

Upload a File

Get the file using a React Native image picker and pass it to MediaMessage:

Send a URL

Send media hosted on your server or cloud storage using the Attachment class:
The MediaMessage class constructor takes the following parameters: On success, sendMediaMessage() returns a MediaMessage object.

Add Caption

Add text along with the media:

Add Metadata and Tags

Multiple Attachments in a Media Message

Starting version 3.0.9 & above, the SDK supports sending multiple attachments in a single media message. A media message can carry up to a configurable maximum number of attachments (default 10, controlled by the file.count.max app setting). sendMediaMessage() rejects with ERR_FILE_COUNT_EXCEEDED if you exceed it — read the current limit at runtime with CometChat.getMaxAttachmentCount().
Recommended: upload first, then send. For a real composer — where you want a progress bar per file, and the ability to remove or retry individual files — upload the files through an UploadFileRequest, collect the resulting Attachments, and attach them here with setAttachments(). This decouples the (slow, cancellable) upload from the (instant) send. See Upload Files & Send Attachments for the full flow.
There are two ways:
  1. By providing an array of files — Pass an array of file objects and CometChat uploads them automatically. This is the simplest path, but it gives no upload progress and no per-file cancel/retry — for that, upload first.
  2. By providing URLs — Use the Attachment class with multiple URLs. This is also the path the upload-then-send flow uses — the Attachments from an UploadFileRequest are ready to pass straight to setAttachments().

Upload Multiple Files

Send Multiple URLs

Custom Message

Send structured data that doesn’t fit text or media categories — like location coordinates, polls, or game moves.
The CustomMessage class constructor takes the following parameters: On success, sendCustomMessage() returns a CustomMessage object.

Add Tags

Quote a Message

Control Conversation Update

By default, custom messages update the conversation’s last message. To prevent this:

Custom Notification Text

Set custom text for push, email, and SMS notifications:

Card Message

A CardMessage is a structured, interactive message rendered as a card bubble. It belongs to the card category and carries a block of Card Schema JSON that the CometChat Cards library draws.
Card Messages cannot be sent through the SDK. The CardMessage class is receive-only — it has no public constructor and the SDK exposes no sendCardMessage() method. Card Messages are created server-side via the Platform (REST) API or the Dashboard Bubble Builder, and delivered to clients like any other message, through the onCardMessageReceived callback of the MessageListener.To create and send a Card Message, use the REST API. See the Send Message REST API reference for the message creation flow.
On the receiving end, the CardMessage object gives you access to the card payload and its related fields.
The CardMessage class provides the following methods: CardMessage extends BaseMessage, so it also exposes the standard message fields (getId(), getSender(), getReceiverId(), getSentAt(), getCategory() = card, etc.). To handle incoming Card Messages on the client, implement onCardMessageReceived on your MessageListener.

Render a Card Message

A CardMessage carries raw Card Schema JSON in getCard(). To draw it natively, pass it to the CometChat Cards renderer (@cometchat/cards-react-native) via the CometChatCardView component. It is a pure renderer: you hand it the card JSON and an action callback, and you own all action behavior (opening URLs, navigating to chats, API calls, etc.). See Campaigns → Rendering Cards for the dependency setup, the CometChatCardView example, and the supported card actions. If the card JSON is empty or invalid, fall back to getFallbackText() (then getText()).

Next Steps

Receive Messages

Listen for incoming messages in real-time

Edit Message

Edit previously sent messages

Delete Message

Delete sent messages