Skip to main content
CometChat supports three types of messages: You can also send metadata along with a text, media or custom message. Think, for example, if you’d want to share the user’s location with every message, you can use the metadata field.

Text Message

Send a text message using CometChat.sendTextMessage() with a TextMessage object.
The TextMessage class constructor takes the following parameters: On success, sendTextMessage() returns a TextMessage object containing all information about the sent message.

Add Metadata

Send custom data along with a text message using the metaData property:

Add Tags

Quote a 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 path and CometChat uploads it automatically
  2. Send a URL — Provide a URL to media hosted on your server or cloud storage

Upload a File

Send a URL

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

Add Caption

Add Metadata and Tags

Same as text messages:

Multiple Attachments in a Media Message

Starting version 3.0.906 & above, the SDK supports sending multiple attachments in a single media message.

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

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:
It is also possible to send interactive messages from CometChat. To learn more, see Interactive Messages.

Next Steps

Receive Messages

Listen for incoming messages in real-time

Edit Message

Edit previously sent messages

Delete Message

Delete sent messages