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. There are two ways:
  1. By providing an array of files — Pass an array of file objects and CometChat uploads them automatically.
  2. By providing URLs — Use the Attachment class with multiple URLs.

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:

Next Steps

Receive Messages

Listen for incoming messages in real-time

Edit Message

Edit previously sent messages

Delete Message

Delete sent messages