Browse SDKs · iOS
Platform
SDKsiOSEnterprise

Save a local transcript

Save a transcript in the current device’s message extension field with OpenIM iOS SDK.

Copy

Audio message models (OIMSoundElem) do not possess built-in properties for storing transcript text. To persist and display transcribed text for a voice message on the current device, save the transcript payload into the message's local extension field (localEx):

Parameters

ParameterTypeRequiredDescription
conversationIDNSString *YesTarget conversation identifier.
clientMsgIDNSString *YesClient message ID of the target audio message.
localExNSString *YesLocal extension JSON string containing the transcript data.
onSuccessOIMSuccessCallbackYesSuccess callback confirming the local record was updated.
onFailureOIMFailureCallbackYesFailure callback returning error code code and descriptive message msg.

Code example

NSString *localEx = [self mergeTranscript:transcript intoLocalEx:message.localEx];
[[OIMManager manager] setMessageLocalEx:conversationID
                            clientMsgID:message.clientMsgID
                                localEx:localEx
                              onSuccess:^(NSString * _Nullable data) {
    // Local extension saved; refresh message bubble UI
}
                              onFailure:^(NSInteger code, NSString * _Nullable msg) {
    // Handle save failure
}];

Return value

The onSuccess callback confirms that the local SQLite database record was updated on the current device.

State changes after the call

  1. Local-only persistence: Updating localEx mutates only the local database record on the current device. It is not synchronized to remote servers or other client devices, and does not trigger remote message events. The client merge key is clientMsgID scoped to conversationID.
  2. Namespace safety: Merge the transcript under a distinct key (e.g. transcript) within existing JSON data rather than overwriting other custom local properties. For general local extension updates, see Set a message’s local extension. For transcription workflows, see Transcribe audio.