Skip to main content

Message overview

The Chat SDK defines the NCMessage class for message transport and management.

NCMessage model

The NCMessage class contains:

  • Transport properties: sender user ID, channel identifier (channel type + channel ID), etc.
  • Message content: the actual payload, either a regular message content (NCMessageContent) or a media message content (NCMediaMessageContent). For example, NCTextMessage is a regular content type, while NCImageMessage is a media content type.

Key NCMessage properties:

PropertyTypeDescription
channelIdentifierNCChannelIdentifierChannel identifier, containing channel type (channelType) and channel ID (channelId)
messageTypeNSStringMessage type identifier string
contentNCMessageContentMessage payload — a subclass of NCMessageContent or NCMediaMessageContent
senderUserIdNSStringSender's user ID
clientIdint64_tLocal database unique ID (locally unique only)
messageIdNSStringServer-assigned globally unique ID (only set after successful send/receive)
directionNCMessageDirectionMessage direction: send or receive
sentTimeint64_tServer timestamp when sent (milliseconds)
sentStatusNCSentStatusSending status: sending, sent, failed, or cancelled
receivedStatusInfoNCMessageReceivedStatusInfoReceiving status: read, listened, downloaded, etc.
metadataNSDictionary<NSString *, NSString *>Message extension metadata (key-value pairs)
hasChangedBOOLWhether the message has been modified
needReceiptBOOLWhether a read receipt is required
sentReceiptBOOLWhether the read receipt has been sent
directedUserIdsNSArray<NSString *>Targeted recipient user IDs (directed message recipients)
disableNotificationBOOLWhether remote push and local notifications are disabled
disableUpdateLastMessageBOOLWhether updating the channel's last message is disabled
isCountedBOOLWhether this message is counted toward the unread total
isPersistedBOOLWhether this message is persisted locally
isStatusMessageBOOLWhether this is a status (transient) message
modifyInfoNCMessageModifyInfoMessage modification details

NCMessageContent

All message content types inherit from one of two base classes:

  • NCMessageContent — regular messages (e.g., NCTextMessage)
  • NCMediaMessageContent — media messages with upload/download handling (e.g., NCImageMessage)

The SDK provides predefined cross-platform message types (text, voice, image, GIF, etc.). You can also create custom message types by subclassing these base classes.

Message storage policy

The NCMessagePersistent property controls how messages are stored locally and on the server, and whether they count toward unread message totals. Built-in message types have default storage policies. Custom message types must conform to the NCMessagePersistentCompatible protocol.