Browse SDKs · iOS
Platform
SDKsiOS

Set a message’s local extension

Update a message’s device-local extension field with OpenIM iOS SDK.

Copy

Invoke setMessageLocalEx:clientMsgID:localEx:onSuccess:onFailure: on OIMManager to store or update custom business metadata (localEx) on a message in the local SQLite database. This field is scoped strictly to the current device and is commonly used for audio playback states, media download flags, or speech-to-text transcripts:

Parameters

ParameterTypeRequiredDescription
conversationIDNSString *YesTarget conversation identifier.
clientMsgIDNSString *YesClient message ID of the target message.
localExNSString *YesCustom extension string (typically in JSON format).
onSuccessOIMSuccessCallbackYesSuccess callback confirming the local record was updated.
onFailureOIMFailureCallbackYesFailure callback returning error code code and descriptive message msg.

Code example

[[OIMManager manager] setMessageLocalEx:conversationID
                            clientMsgID:message.clientMsgID
                                localEx:@"{\"downloaded\":true}"
                              onSuccess:^(NSString * _Nullable data) {
    // Local extension updated successfully
}
                              onFailure:^(NSInteger code, NSString * _Nullable msg) {
    // Handle update failure
}];

Return value

The onSuccess callback confirms that localEx was updated in the device's local database.

State changes after the call

  1. Local-only persistence: This operation modifies local device storage only. It does not send network updates to the server, does not notify other devices or users, and does not trigger incoming message listeners (onRecvNewMessage:).
  2. Full replacement: The method performs a complete string replacement of localEx. To preserve existing properties, parse the current localEx JSON, merge new keys into it, and write back the consolidated string. For an example saving speech transcription text, see Save a local transcript.