SDKsuni-app / uni-app x
Create a text message
Construct a pending text message object from a string.
Invoke createTextMessage() to construct a pending text message object from a string. Validate length, whitespace, and compliance constraints in your UI layer prior to invocation.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
text | string | Yes | Text content string to transmit. |
Code example
import { createTextMessage } from '@/uni_modules/unix-openim-sdk'
const text = input.trim()
if (text.length == 0) return
const message = await createTextMessage(text)
if (message == null) returnReturn value
The Promise resolves with an OpenIMMessageItem | null object. Message creation only instantiates the message structure in local memory; it does not persist data to the server or emit incoming message events.
State changes after the call
Pass the returned message item to Send a message. Track and update the message status in your UI state using the returned clientMsgID.
Was this page helpful?