Skip to main content
Quick Reference for AI Agents & Developers
  • Send text: CometChat.sendTextMessage(message:onSuccess:onError:)
  • Send media: CometChat.sendMediaMessage(message:onSuccess:onError:)
  • Receive messages: CometChat.addMessageListener("UNIQUE_ID", self)
  • Fetch history: MessagesRequest.MessageRequestBuilder().build()messagesRequest.fetchPrevious(onSuccess:onError:)
  • Message types: TextMessage, MediaMessage, CustomMessage, InteractiveMessage (all extend BaseMessage)
  • Related: Send Message · Receive Message · Typing Indicators
Messaging is one of the core features of CometChat. We’ve thoughtfully created methods to help you send, receive and fetch message history. At the minimum, you must add code for sending messages and receiving messages. Once you’ve implemented that, you can proceed to more advanced features like typing indicators and delivery & read receipts.

Message Data Models

All message types in CometChat inherit from the BaseMessage class. Understanding these data models is essential for working with messages.

BaseMessage Properties

The BaseMessage class contains properties common to all message types:

TextMessage

Extends BaseMessage with:

MediaMessage

Extends BaseMessage with:

CustomMessage

Extends BaseMessage with:

Attachment


Success & Failure Responses

Send Message Success

When a message is sent successfully, you receive the complete message object with server-assigned properties:

Common Error Codes