Browse SDKs · HarmonyOS
Platform
SDKsHarmonyOSEnterprise

Update local message content

Replace full message contents directly within the local device database.

Copy

This operation modifies only the local message record on the current device. The API expects a complete IMMessage object rather than isolated partial fields.

Code example

import sdk, { IMMessage, SetMessageLocalContentReq } from '@openimsdk/imsdk';

const localMessage: IMMessage = cloneMessage(message);
if (localMessage.textElem !== undefined) {
  localMessage.textElem.content = 'Device-local updated text';
}

const request: SetMessageLocalContentReq = {
  conversationID: conversationID,
  message: localMessage,
};
await sdk.setMessageLocalContent(request);

Parameters

ParameterTypeRequiredDescription
conversationIDstringYesTarget conversation identifier.
messageIMMessageYesComplete message object with modified local contents.

Return value

Returns a Promise that resolves to void when the local database write completes.

State changes after the call

In the example, cloneMessage represents a type-safe deep clone helper implemented by your application. The updated message object must preserve original keys and mandatory properties; do not pass an object containing only clientMsgID and partial content. Promise resolution does not upload modifications to OpenIMServer, synchronize to other devices, or fire shared message events. If you only need to store auxiliary application data like voice transcripts, saving them to local extensions via Set message local extension is usually preferable.