Browse SDKs · React Native
Platform
SDKsReact Native

Create advanced text message

Construct a rich-text message with embedded entities such as URLs and styling spans using the OpenIM React Native SDK.

Copy

Construct a rich-text message containing embedded entities:

const message = await OpenIMSDK.createAdvancedTextMessage({
  text: 'Check https://openim.io',
  messageEntityList: [
    {
      type: 'url',
      offset: 6,
      length: 17,
      url: 'https://openim.io',
    },
  ],
});

Parameters

ParameterTypeRequiredDescription
textstringYesRaw string content of the rich-text message.
messageEntityListMessageEntity[]NoArray of rich-text entities describing links, highlights, or custom spans.

Each MessageEntity includes type, offset, and length, and can optionally provide url and info.

Return value

A resolved Promise returns the initialized MessageItem object with rich-text attributes populated in advancedTextElem.

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.