SDKsReact Native
Create custom message
Construct a custom business message with arbitrary structured payload using the OpenIM React Native SDK.
Construct a custom business message with arbitrary structured payloads:
Both the sending and receiving applications must align on serialization schemas for data and extension.
const message = await OpenIMSDK.createCustomMessage({
data: JSON.stringify({ type: 'task', taskID: 'task-42' }),
extension: JSON.stringify({ version: 1 }),
description: 'Task Card',
});Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
data | string | Yes | Business payload string, typically serialized JSON. |
extension | string | Yes | Custom extension payload string. |
description | string | Yes | Message summary text, often displayed as fallback preview text on older client versions. |
Return value
A resolved Promise returns the initialized MessageItem object with payload attributes stored in customElem.
This method builds the message structure strictly in client memory; it does not dispatch messages to the server or trigger lifecycle events. After initialization, invoke Send message to deliver it to a one-to-one or group conversation. For server push notifications outside chat conversations, see Receive custom business messages.
Was this page helpful?