Message overview
The Nexconn SDK defines the Message class for transmitting and managing messages.
Message model
The Message class encapsulates the following key data:
- Transmission properties: Sender ID, receiver ID, channel type, and other routing information.
- Message content: The actual payload of a message, represented by a subclass of
MessageContent(for standard messages) orMediaMessageContent(for media messages). For example,TextMessageis a standard message content type, whileImageMessageis a media message content type. The content type determines which send method to use.
In this documentation, "message" (e.g., text message, voice message) sometimes refers to the specific content class that extends MessageContent or MediaMessageContent.
The following table describes the key properties of the Message class. For a complete list, see the API reference.
| Property | Type | Description |
|---|---|---|
| messageType | String | The identifier for the message type. See Message type overview. |
| content | MessageContent? | The actual message payload. Must be a subclass of MessageContent or MediaMessageContent. The Chat SDK provides built-in message types with cross-platform consistent structures (see Message type overview), such as text, voice, image, and GIF. You can also create custom message types. |
| channelIdentifier | ChannelIdentifier | Channel identifier containing channel type and channel ID. Use channelIdentifier.channelType and channelIdentifier.channelId to access them. See Channel overview. |
| senderUserId | String? | The user ID of the message sender. |
| clientId | Int | The local message ID, a unique auto-increment index in local storage. |
| messageId | String? | The server-assigned globally unique message ID. Only set for successfully sent messages. |
| direction | MessageDirection | The message direction enum: SEND or RECEIVE. |
| sentTime | Long | The server timestamp (in milliseconds, UNIX epoch) when the message arrived at the server. |
| sentStatus | SentStatus | The send status: NONE, SENDING, SENT, FAILED, CANCELED, RECEIVED, READ, or DESTROYED. |
| receivedStatusInfo | MessageReceivedStatusInfo | The received message status info, including isRead, isDownloaded, isListened, isRetrieved, and isMultipleReceive. See Message received status. |
| metadata | Map<String, String>? | The message metadata in key-value format. Supports remote sync. See Message metadata. |
| needReceipt | Boolean | Whether a read receipt is required. See Read receipt. |
| sentReceipt | Boolean | Whether a read receipt has been sent. See Read receipt. |
| modifyInfo | MessageModifyInfo? | Message modification info. See Update messages. |
| isCounted | Boolean | Whether this message is counted for unread count. |
| isPersisted | Boolean | Whether this message is persisted in local storage. |
MessageContent
The Message class contains a content property representing the actual message payload. Message content types must extend one of these base classes:
MessageContent— The base class for standard message content. For example, the built-inTextMessageextendsMessageContent.MediaMessageContent— The base class for media message content. It extendsMessageContentand adds media file handling logic. For example, the built-inImageMessageextendsMediaMessageContent. When sending or receiving media messages, the SDK automatically handles file upload and download.
The Chat SDK provides built-in, cross-platform consistent message content types (see Message type overview), including text, voice, image, and GIF. To create custom messages, extend MessageContent or MediaMessageContent.
Message storage policy
The client SDK and server use the MessageTag annotation to identify a message's type, storage policy, and whether it counts toward the unread count. MessageTag is a Java annotation applied to message content classes. Every class that extends MessageContent or MediaMessageContent must have a MessageTag annotation.
For built-in message types, the MessageTag is automatically applied. No extra configuration is needed.
To create custom message types, learn how to set up message annotations correctly: