SDKsiOS
Set a message’s local extension
Update a message’s device-local extension field with OpenIM iOS SDK.
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
| Parameter | Type | Required | Description |
|---|---|---|---|
conversationID | NSString * | Yes | Target conversation identifier. |
clientMsgID | NSString * | Yes | Client message ID of the target message. |
localEx | NSString * | Yes | Custom extension string (typically in JSON format). |
onSuccess | OIMSuccessCallback | Yes | Success callback confirming the local record was updated. |
onFailure | OIMFailureCallback | Yes | Failure 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
- 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:). - Full replacement: The method performs a complete string replacement of
localEx. To preserve existing properties, parse the currentlocalExJSON, merge new keys into it, and write back the consolidated string. For an example saving speech transcription text, see Save a local transcript.
Was this page helpful?