Browse SDKs · iOS
Platform
SDKsiOS

Create a custom message

Create a structured application-defined message with OpenIM iOS SDK.

Copy

Invoke createCustomMessage:extension:description: on OIMMessageInfo to construct a message carrying structured business payloads (such as order cards, polls, red packets, or custom transfer receipts):

Parameters

ParameterTypeRequiredDescription
dataNSString *YesSerialized custom business JSON payload string.
extensionNSString *YesCustom protocol identifier or payload type (such as com.example.order).
descriptionNSString *YesFallback summary string displayed in conversation previews or legacy clients.

Code example

OIMMessageInfo *message =
    [OIMMessageInfo createCustomMessage:jsonString
                              extension:@"com.example.order"
                            description:@"[Order Card]"];

Return value

Returns an initialized OIMMessageInfo instance configured as a custom message.

State changes after the call

  1. Local memory instantiation: This method creates an in-memory object only. Receiving clients must validate protocol schemas; critical business states (such as payment processing) must be verified by backend servers.
  2. Subsequent dispatch: Deliver this message to a user or group conversation by calling Send a message.