Browse SDKs · uni-app / uni-app x
Platform
SDKsuni-app / uni-app x

Create a text message

Construct a pending text message object from a string.

Copy

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

ParameterTypeRequiredDescription
textstringYesText 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) return

Return 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.