SDKsiOS
Create a rich-text message
Create an advanced text message with entity annotations using OpenIM iOS SDK.
Invoke createAdvancedTextMessage:messageEntityList: on OIMMessageInfo to construct a rich-text message containing formatted entity spans (such as hyperlinks, tags, or mentions):
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
text | NSString * | Yes | Complete plain text body of the rich-text message. |
messageEntityList | NSArray<OIMMessageEntity *> * | Yes | Array 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
- Local memory instantiation: This method builds an in-memory message model without persisting records to local storage or making network requests.
- Span boundary alignment: Ensure that the
offsetandlengthof each entity accurately correspond to character indices withintext. - Subsequent dispatch: Call Send a message to deliver the rich-text message.
Was this page helpful?