SDKsHarmonyOSEnterprise
Insert local group message
Insert a local-only message into the group chat history on the current device.
Inserts a synthetic or migrated message directly into the local device database for a group chat.
Code example
import sdk, { InsertGroupMessageToLocalReq, InsertGroupMessageToLocalResp } from '@openimsdk/imsdk';
const request: InsertGroupMessageToLocalReq = {
msg: message,
groupID: groupID,
sendID: currentUserID,
};
const response: InsertGroupMessageToLocalResp = await sdk.insertGroupMessageToLocal(request);
insertMessage(response.msg);Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
msg | IMMessage | Yes | Message object to insert into the local database. |
groupID | string | Yes | Target group identifier. |
sendID | string | Yes | Sender user ID shown on the message bubble. |
Return value
Returns a Promise resolving to InsertGroupMessageToLocalResp:
| Property | Type | Description |
|---|---|---|
msg | IMMessage | The inserted message object with initialized database state. |
State changes after the call
groupID and sendID must match the message routing and display context. Merge the inserted item into UI feeds using clientMsgID (qualified by conversationID as needed). Resolving the Promise modifies only the local database of the current device; it does not dispatch messages to group members or trigger shared message arrival events. To insert a local message in single chat, see Insert local single message.
Was this page helpful?