Browse SDKs · uni-app / uni-app x
Platform
SDKsuni-app / uni-app xEnterprise

Save local transcript

Replace the content payload of a message directly in the local device database.

Copy

Updating local message content is a Commercial Edition capability used to replace message payload content stored in the device's local database. It accepts a complete OpenIMMessageItem struct rather than updating individual string fields in isolation.

The following example demonstrates updating a local message's text element. Retain all original message headers and update the element matching contentType:

import {
  OpenIMMessageItem,
  setMessageLocalContent,
} from '@/uni_modules/unix-openim-sdk'

const updatedMessage = JSON.parse<OpenIMMessageItem>(
  JSON.stringify(message),
)
const textElem = updatedMessage.textElem
if (textElem == null) return

textElem.content = 'Text displayed exclusively on this device'
updatedMessage.textElem = textElem

await setMessageLocalContent({
  conversationID,
  message: updatedMessage,
})

Parameters

ParameterTypeRequiredDescription
conversationIDstringYesIdentifier of the conversation containing the message.
messageOpenIMMessageItemYesFull message struct retaining original identifiers and updated content elements.

Clone the object via serialization to avoid modifying in-memory references directly, and avoid passing abbreviated objects that omit mandatory message properties.

Return value

The Promise resolves with void upon successful local database persistence.

State changes after the call

Promise resolution indicates that the local database record was updated. This change is never transmitted to OpenIMServer, does not synchronize to other participants, and does not emit shared network message events. Update your local UI state using conversationID:clientMsgID.

Note that OpenIMSoundElem in the UniApp SDK does not expose a dedicated voice transcription property. If your application needs to persist voice transcriptions or auxiliary presentation flags without modifying the message element itself, see Set message local extension to store data in localEx.