Message overview
Learn about the OpenIM React Native SDK message model, message lifecycle, and message event listeners.
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
| Stage | Capability | Description |
|---|---|---|
| Create | create*Message() | Initializes a local MessageItem instance ready for sending without calling the server. |
| Send | Send message, Send uploaded media message | Dispatches the message to a one-to-one or group conversation. |
| Receive | Message events | Receives real-time, offline, and online-only incoming messages. |
| Query | History, lookup by ID, search | Retrieves and paginates historical messages from local cache and server. |
| State changes | Revoke, delete, modify, read receipts | Reconciles 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:
| Field | Type | Description |
|---|---|---|
clientMsgID | string | Unique client-generated message ID, used for deduplication, updates, and indexing. |
serverMsgID | string | Unique server-assigned message ID. |
sessionType | SessionType | Conversation type, distinguishing one-to-one chats from group chats. |
sendID | string | Sender user ID. |
recvID | string | Recipient user ID for one-to-one messages. |
groupID | string | Target group ID for group messages. |
contentType | MessageType | Message content type, determining which payload element to render. |
createTime | number | Timestamp when the message object was created. |
sendTime | number | Timestamp when the message was dispatched. |
seq | number | Server-assigned message sequence number. |
senderPlatformID | Platform | Platform identifier of the sending client. |
status | MessageStatus | Transmission status of the message. |
isRead | boolean | Read receipt state for the message. |
senderNickname | string | Display nickname of the sender. |
senderFaceUrl | string | Avatar URL of the sender. |
offlinePush | OfflinePush | Offline push notification payload configuration. |
content | string | Serialized message payload. For UI rendering, read the specific element corresponding to contentType. |
ex | string | Custom global extension field synchronized across clients. |
localEx | string | Custom local-only extension string stored exclusively on the current device. |
Message content payloads are stored in specific element fields matching contentType:
| Content payload | Field |
|---|---|
| Text, rich text, and Markdown | textElem, advancedTextElem, markdownTextElem |
| Image, audio, video, and file | pictureElem, soundElem, videoElem, fileElem |
| Mention (@) message | atTextElem |
| Quote reply message | quoteElem |
| Merged forward | mergeElem |
| Business card, location, and face/sticker | cardElem, locationElem, faceElem |
| Custom business message | customElem |
| System notification, typing indicator, attached info | notificationElem, 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.
| Content type | Guide |
|---|---|
| Text and rich text | Create text message, Create rich-text message |
| Mention (@) | Create @ message |
| Image, audio, video, and file | Create image message from file, Create audio message from file, Create video message from file, Create file message from file |
| Business card, location, and face | Create card message, Create location message, Create face message |
| Reply, forward, and merged forward | Create quote message, Create forward message, Create merger message |
| Custom message | Create custom message |
Capabilities by task
| Task | Guide |
|---|---|
| Receive real-time, offline, and online-only messages | Receive messages |
| Receive custom business messages | Receive custom business messages |
| Load message history or message context | Load older messages, Load message context |
| Find or search messages by ID | Find messages by ID, Search messages |
| Delete, revoke, or modify messages | Delete saved messages, Revoke a message, Modify a message |
| Manage device-local message data | Delete local message, Set message local extension |
| Report or query group read receipts | Send group read receipts, Get group message readers |
| Report or query typing status | Update typing status, Get typing status |
| Audio transcription | Check speech-to-text, Transcribe audio |
Event handling
Complete event listener implementations and registration patterns are documented on their dedicated pages:
- New messages, offline messages, and online-only messages:
OnRecvNewMessage,OnRecvOfflineNewMessage,OnRecvOnlineOnlyMessage. See Receive messages. - Custom business messages:
OnRecvCustomBusinessMessage. See Receive custom business messages. - Message deletion:
OnMsgDeletedEnterprise. See Delete saved messages. - Message revocation:
OnNewRecvMessageRevoked. See Revoke a message. - Message modification:
OnMessageModifiedEnterprise. See Modify a message. - Group message read receipts:
OnRecvGroupReadReceiptEnterprise. See Send group read receipts. - Typing status changes:
OnInputStatusChanged. See Change input states.
Was this page helpful?