Browse SDKs · iOS
Platform
SDKsiOS

Create a rich-text message

Create an advanced text message with entity annotations using OpenIM iOS SDK.

Copy

Invoke createAdvancedTextMessage:messageEntityList: on OIMMessageInfo to construct a rich-text message containing formatted entity spans (such as hyperlinks, tags, or mentions):

Parameters

ParameterTypeRequiredDescription
textNSString *YesComplete plain text body of the rich-text message.
messageEntityListNSArray<OIMMessageEntity *> *YesArray of rich-text entity objects defining formatting spans. Each entity specifies type, offset, length, and optional target URL or metadata.

Code example

OIMMessageInfo *message =
    [OIMMessageInfo createAdvancedTextMessage:text
                            messageEntityList:entities];

Return value

Returns an initialized OIMMessageInfo model with its content type set to advanced text.

State changes after the call

  1. Local memory instantiation: This method builds an in-memory message model without persisting records to local storage or making network requests.
  2. Span boundary alignment: Ensure that the offset and length of each entity accurately correspond to character indices within text.
  3. Subsequent dispatch: Call Send a message to deliver the rich-text message.