Skip to main content
FieldValue
Key ClassesTextMessage, MediaMessage, CustomMessage
Key MethodssendTextMessage(), sendMediaMessage(), sendCustomMessage()
Receiver Types.user, .group
Message Types.text, .image, .video, .audio, .file, custom
PrerequisitesSDK initialized, user logged in
CometChat supports four types of messages:
TypeMethodUse Case
TextsendTextMessage()Plain text messages
MediasendMediaMessage()Images, videos, audio, files
CustomsendCustomMessage()Location, polls, or any JSON data
CardReceive-onlyStructured, interactive card bubbles (created via the REST API)
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:
ParameterDescriptionRequired
receiverIDUID of the user or GUID of the group receiving the messageYes
textThe text message contentYes
receiverType.user or .groupYes
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:
ParameterDescriptionRequired
receiverIDUID of the user or GUID of the groupYes
fileurlFile path or empty string if using URLYes
messageType.image, .video, .audio, or .fileYes
receiverType.user or .groupYes
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:
ParameterDescriptionRequired
receiverIDUID of the user or GUID of the groupYes
receiverType.user or .groupYes
customDataDictionary with your custom dataYes
typeYour custom type string (e.g., "location", "poll")Yes
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:

Card Message

In other words, as a sender, how do I send a 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.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:
MethodReturnsDescription
getCard()[String: Any]?The raw card schema/payload passed to the Cards renderer.
getText()String?Optional text shown alongside the card.
getFallbackText()String?Text displayed when the card payload cannot be rendered.
getTags()[String]?Tags associated with the message.
CardMessage extends BaseMessage, so it also exposes the standard message fields (id, sender, receiverUid, sentAt, category = card, etc.). To handle incoming Card Messages on the client, implement onCardMessageReceived on your CometChatMessageDelegate.

Next Steps

Receive Messages

Listen for incoming messages in real-time

Edit Message

Edit previously sent messages

Delete Message

Delete sent messages