Browse SDKs · iOS
Platform
SDKsiOSIncludes Enterprise features

Messages overview

Understand message creation, sending, reception, and local storage in OpenIM iOS SDK.

Copy

Message capabilities in the OpenIM iOS SDK center on the OIMMessageInfo model. Plain text messages and media messages created from local files are initialized via corresponding OIMMessageInfo factory class methods, then sent through Send a message. If media files have already been uploaded by your application to object storage and public URLs are available, create messages using URL-based factory methods and send them via Send a message without OSS.

Both delivery pathways support one-to-one and group chats. Incoming messages, message revocations, deletions, read receipts, media upload progress, and conversation updates synchronize to the application through listener protocols and delegates.

Client-side message interfaces and state stores maintain the following core identifiers:

IdentifierDescription
clientMsgIDStable client-generated unique message identifier, used for list deduplication, state updates, queries, and pagination cursors.
conversationIDConversation record identifier, used for history queries, searching, and unread count tracking. Take directly from conversation data rather than deriving from array indices.
recvIDRecipient user ID for one-to-one messages. Pass nil when sending group messages.
groupIDTarget group ID for group messages. Pass nil when sending one-to-one messages.

Message types

Initialize OIMMessageInfo instances for each content type using dedicated class methods. The sending layer dispatches all message models uniformly without requiring separate transport channels for different formats.

Message type comparison

Content typeTypical use caseGuide
Plain textStandard text chat messages.Create a text message
@ Mention textMention one or more members in a group chat.Create an @ message
ImageCreate image messages from local files or hosted URLs.Create an image message from a local path
AudioCreate voice and sound recording messages.Create an audio message from a local path
VideoCreate video messages with video snapshot covers.Create a video message from a local path
FileCreate general file attachments.Create a file message from a local path
Custom messageStructured business payloads (cards, red packets, orders).Create a custom message
MarkdownRich text formatted with Markdown syntax.Create a Markdown message

When the SDK should handle media uploads, use path-based factory methods and Send a message. When your backend already hosts the files, use URL-based creation methods and Send a message without OSS to bypass the built-in upload pipeline. Store data that must be shared across devices inside the message payload, and store private rendering state in localEx.

Common OIMMessageInfo properties

PropertyTypeDescription
clientMsgIDNSString * _NullableClient message ID used as the primary deduplication and merge key.
serverMsgIDNSString * _NullableServer message ID, which does not replace clientMsgID for local merging.
sessionTypeOIMConversationTypeConversation type (one-to-one or group) used to route the message.
sendIDNSString * _NullableUser ID of the message sender.
recvIDNSString * _NullableUser ID of the recipient in one-to-one chats.
groupIDNSString * _NullableGroup ID in group chats.
contentTypeOIMMessageContentTypeContent type enumeration determining which element to parse and render.
sendTimeNSTimeIntervalTimestamp when the message was sent, used for chronological sorting.
statusOIMMessageStatusMessage dispatch status (sending, succeeded, failed).
isReadBOOLRead receipt status of the message.

Specific content properties such as textElem, pictureElem, soundElem, videoElem, fileElem, atTextElem, and customElem are populated based on contentType. Validate that both contentType and the corresponding element are non-nil when rendering views, providing fallback placeholders if content is absent.

Message handling pipeline

  1. Construct the message object locally using an OIMMessageInfo factory method.
  2. Call Send a message or Send a message without OSS to dispatch to a user or group.
  3. On the sender client, update UI bubble states using clientMsgID upon success or progress callbacks; receiving clients capture new messages via OIMAdvancedMsgListener.
  4. When opening a conversation view, fetch an initial history snapshot, then maintain state by listening for incoming messages, revocations, deletions, and read receipts.

Message creation factory methods instantiate models in local memory without initiating network requests or triggering events. Callback completion, asynchronous listener notifications, and cache reconciliation queries operate as three distinct stages.

Conversation routing rules

When sending one-to-one messages, supply recvID and set groupID to nil. When sending group messages, supply groupID and set recvID to nil. Deduplicate messages in local storage using clientMsgID scoped to conversationID; never use array positions or text summaries as primary keys.

Feature navigation

Sending and receiving

Retrieval and searching

Message management and read status

Composition and transcription