Browse SDKs · HarmonyOS
Platform
SDKsHarmonyOSEnterprise

Create forward message

Create a forwardable message from an existing single message.

Copy

Creates a new message object suitable for forwarding an existing message to another conversation.

Code example

import sdk, { CreateForwardMessageReq, CreateForwardMessageResp } from '@openimsdk/imsdk';

const request: CreateForwardMessageReq = { message: sourceMessage };
const response: CreateForwardMessageResp = await sdk.createForwardMessage(request);
const message = response.message;

Parameters

ParameterTypeRequiredDescription
messageIMMessageYesExisting message to be forwarded.

Return value

Returns a Promise resolving to CreateForwardMessageResp:

PropertyTypeDescription
messageIMMessageLocally instantiated forward message object.

State changes after the call

The source message should originate from query results or message events and must have already been sent successfully. Verify that the user has authorization to distribute the content before forwarding. Local file paths, expired asset URLs, and device-local extensions cannot be assumed valid in destination conversations. This operation creates the message object locally without altering the original message or picking destination targets; call Send message to dispatch it to a direct or group chat.