Browse SDKs · React Native
Platform
SDKsReact NativeIncludes Enterprise features

Message overview

Learn about the OpenIM React Native SDK message model, message lifecycle, and message event listeners.

Copy

OpenIM React Native SDK represents every message using the MessageItem structure. Creating a message creates a client-side MessageItem ready to be dispatched; to send it to a one-to-one user or a group, call the appropriate sending API. Incoming messages, queries, and lifecycle state changes (deletion, revocation, modification, read receipts) are processed through their respective APIs and event listeners.

Message lists rely on clientMsgID as the primary identifier to deduplicate, update, and locate individual messages. Note that MessageItem does not contain a conversationID property; obtain the message's conversation context from active conversation state, history query parameters, or event metadata.

Message lifecycle workflow

StageCapabilityDescription
Createcreate*Message()Initializes a local MessageItem instance ready for sending without calling the server.
SendSend message, Send uploaded media messageDispatches the message to a one-to-one or group conversation.
ReceiveMessage eventsReceives real-time, offline, and online-only incoming messages.
QueryHistory, lookup by ID, searchRetrieves and paginates historical messages from local cache and server.
State changesRevoke, delete, modify, read receiptsReconciles message status transitions via API results and incremental events.

MessageItem structure

All creation, transmission, reception, and query APIs return MessageItem objects. Common core properties include:

FieldTypeDescription
clientMsgIDstringUnique client-generated message ID, used for deduplication, updates, and indexing.
serverMsgIDstringUnique server-assigned message ID.
sessionTypeSessionTypeConversation type, distinguishing one-to-one chats from group chats.
sendIDstringSender user ID.
recvIDstringRecipient user ID for one-to-one messages.
groupIDstringTarget group ID for group messages.
contentTypeMessageTypeMessage content type, determining which payload element to render.
createTimenumberTimestamp when the message object was created.
sendTimenumberTimestamp when the message was dispatched.
seqnumberServer-assigned message sequence number.
senderPlatformIDPlatformPlatform identifier of the sending client.
statusMessageStatusTransmission status of the message.
isReadbooleanRead receipt state for the message.
senderNicknamestringDisplay nickname of the sender.
senderFaceUrlstringAvatar URL of the sender.
offlinePushOfflinePushOffline push notification payload configuration.
contentstringSerialized message payload. For UI rendering, read the specific element corresponding to contentType.
exstringCustom global extension field synchronized across clients.
localExstringCustom local-only extension string stored exclusively on the current device.

Message content payloads are stored in specific element fields matching contentType:

Content payloadField
Text, rich text, and MarkdowntextElem, advancedTextElem, markdownTextElem
Image, audio, video, and filepictureElem, soundElem, videoElem, fileElem
Mention (@) messageatTextElem
Quote reply messagequoteElem
Merged forwardmergeElem
Business card, location, and face/stickercardElem, locationElem, faceElem
Custom business messagecustomElem
System notification, typing indicator, attached infonotificationElem, typingElem, attachedInfoElem

All payload elements are optional fields on MessageItem. Inspect contentType first to determine which element to parse and render.

Create and send messages

Invoke the dedicated creation method to construct a MessageItem, then invoke the appropriate sending API. Use Send message when the SDK handles uploading local media files; use Send uploaded media message when media files already have pre-uploaded remote URLs.

Capabilities by task

TaskGuide
Receive real-time, offline, and online-only messagesReceive messages
Receive custom business messagesReceive custom business messages
Load message history or message contextLoad older messages, Load message context
Find or search messages by IDFind messages by ID, Search messages
Delete, revoke, or modify messagesDelete saved messages, Revoke a message, Modify a message
Manage device-local message dataDelete local message, Set message local extension
Report or query group read receiptsSend group read receipts, Get group message readers
Report or query typing statusUpdate typing status, Get typing status
Audio transcriptionCheck speech-to-text, Transcribe audio

Event handling

Complete event listener implementations and registration patterns are documented on their dedicated pages: