Browse SDKs · React Native
SDKsReact Native

Create a custom message

OpenIM React Native SDK guide for create a custom message.

Copy

Use createCustomMessage() to create a custom business message. The sending and receiving applications must agree on the formats of 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 data string. It can contain JSON.
extensionstringYesBusiness extension data string.
descriptionstringYesMessage description. It can also be fallback text for clients that do not support the message type.

The call returns a MessageItem ready to send. Receiving clients should validate the business-data format and version. For server-delivered business notifications, see Receive custom business messages.