Browse SDKs · React Native
Platform
SDKsReact Native

Create custom message

Construct a custom business message with arbitrary structured payload using the OpenIM React Native SDK.

Copy

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

ParameterTypeRequiredDescription
datastringYesBusiness payload string, typically serialized JSON.
extensionstringYesCustom extension payload string.
descriptionstringYesMessage 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.