Create a custom message
OpenIM uni-app / uni-app x SDK guide for Create a custom message.
Use createCustomMessage() for orders, tasks, invitations, polls, or other business messages whose schema is shared by sender and receiver.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
data | string | Yes | Complete business payload, normally serialized JSON. |
extension | string | Yes | Complete business extension string. |
descriptionText | string | Yes | Type description or fallback text for unsupported clients. |
import { createCustomMessage } from '@/uni_modules/unix-openim-sdk'
const message = await createCustomMessage({
data: JSON.stringify({ type: 'task', taskID: 'task_42' }),
extension: JSON.stringify({ schemaVersion: 1 }),
descriptionText: 'Task card',
})All three fields reach the recipient. Never store secrets; validate schema version, size, and fields before mapping to a business model, and never execute untrusted content. The uni-app / uni-app x contract does not include the Wasm commercial searchText parameter. The Promise creates OpenIMMessageItem | null; sending and custom business events are separate flows.
Advanced text messages
createAdvancedTextMessage() creates entity/styled text from OpenIMCreateAdvancedTextMessageParams. Entity ranges must refer to indexes in the original text; reject out-of-range values before calling the SDK. Both APIs only create messages.
Was this page helpful?