please select
  • UIKit
  • SDK
  • Server APIs
Chat/
SDK/
Flutter/
Message/
SDK
  • Install Chat SDK
    • Install
  • Initialize Chat SDK
    • Initialize
  • Login And Logout
    • Login and Logout
  • Message
    • Message Overview
    • Sending Message
    • Receiving Message
    • Historical Message
    • Forwarding Message
    • Modifying Message
    • Message Inserting
    • Deleting Message
    • Clearing Messages
    • Recalling Message
    • Online Message
    • Read Receipt
    • Querying Message
    • Group @ Message
    • Targeted Group Message
    • Notification Muting
    • Message Extension
  • Conversation
    • Conversation Overview
    • Conversation List
    • Getting Conversation
    • Conversation Unread Count
    • Pinning Conversation to the Top
    • Deleting Conversation
    • Conversation Draft
    • Conversation Group
  • Group
    • Group Overview
    • Group Management
    • Group Profile
    • Group Member Management
    • Group Member Profile
    • Custom Group Attribute
  • User
    • User Profile
    • Friend Management
    • Friend List
    • Blocklist
  • Offline Push
    • Offline Push
  • Signaling
    • Signaling Management
  • Local Search
    • Searching for Message
    • Searching for Friend
    • Searching Group
    • Searching for Group Member
  • API Reference
    • Client APIs
  • Guideline for Beginners
  • Console Guide
    • Creating and Upgrading an Application
    • Basic Configuration
    • Feature Configuration
    • Account Management
    • Group Management
    • Webhook Configuration
  • Product Introduction
    • Message Management
      • One-to-One Message
      • Message Storage
      • Offline Push
      • Group Message
      • Message Formats
    • Account System
      • Login Authentication
      • Online Status Management
    • Group Related
      • Group System
      • Group Management
    • User Profile and Relationship Chain
      • Profile Management
      • Relationship Chain Management
  • Purchase Guide
    • Billing Overview
    • Pricing
  • Error Codes

Forwarding Message

Feature Description

You can merge and forward messages as provided by WeChat in the following steps:
1. Create a merged message based on the list of original messages.
2. Send the merged message to the receiver.
3. The receiver receives the merged message and parses the list of original messages.
The title and digest are needed to display the merged message, as shown below:
Merge and Forward
Display of Merged Message
Click Merged Message to Download Message List for Display




Merging and Forwarding Messages

Creating and sending a merged message

A merged message can be created by setting the message list along with the merged message title and digest. The process is as follows:
1. Call the createMergerMessage API (Details) to create a merged message. The list of original messages as well as the merged message title and digest also need to be set.

Attribute
Description
Remarks
msgIDList
List of IDs of original messages
List of IDs of original messages to be merged and forwarded
title
Title
Title of the merged message, such as "Chat History of xixiyah and Hello" as shown above
abstractList
Digest list
Digest list of the merged message as shown above. The original message digests need to be displayed for the merged message, which will be unfolded after the user clicks the cell.
compatibleText
Compatibility text message
If the early SDK version does not support the merged message, the user will receive a text message with the content compatibleText by default.
Sample code for creating and sending a merged message:
// List of messages to be forwarded, which can contain merged messages but not group tips
V2TimValueCallback<V2TimMsgCreateInfoResult> createMergerMessageResult =
await TencentImSDKPlugin.v2TIMManager
.getMessageManager()
.createMergerMessage(
msgIDList: ["msgid1", "msgid2"],
title: "Chat History of user1 and user2", // Title of the merged message
abstractList: ["user1:hello", "user2:hello"], // Digest list of the merged message
compatibleText: "The current version does not support the message", // Compatibility text of the merged message. If the early SDK version does not support the merged message, the user will receive a text message with the content `compatibleText` by default.
);
if (createMergerMessageResult.code == 0) {
TencentImSDKPlugin.v2TIMManager.getMessageManager().sendMessage(
id: createMergerMessageResult.data.id,
receiver: "",
groupID: "",
);
}

Receiving a merged message

Adding a listener

The receiver calls addAdvancedMsgListener (Details) to add the advanced message listener. We recommend it be called early, such as after the chat page is initialized, to ensure timely message receiving in the application.
Sample code:
TencentImSDKPlugin.v2TIMManager
.getMessageManager()
.addAdvancedMsgListener(listener: listener);

Parsing a message

After the listener is added, the receiver will receive the merged message V2TimMessage in onRecvNewMessage. You can use the merged message element V2TimMergerElem (Details) to get the title and abstractList for UI display. Then, when the user clicks the merged message, you can call the downloadMergerMessage API (Details) to download the merged message list for UI display.
Sample code:
if(message.elemType == MessageElemType.V2TIM_ELEM_TYPE_MERGER){
message.mergerElem.abstractList;
message.mergerElem.isLayersOverLimit;
message.mergerElem.title;
V2TimValueCallback<List<V2TimMessage>> download = await TencentImSDKPlugin.v2TIMManager.getMessageManager().downloadMergerMessage(msgID: message.msgID,);
if(download.code == 0){
List<V2TimMessage> messageList = download.data;
}
}

Forwarding Messages One by One

To forward a single message, create a message identical to the original message through the createForwardMessage API (Details) first, and then call the sendMessage API (Details) to send the message.
Sample code:
// Create a message with the same elements as the original message
V2TimValueCallback<V2TimMsgCreateInfoResult> createForwardMessageRes = await TencentImSDKPlugin.v2TIMManager.getMessageManager().createForwardMessage(msgID: "msgid");
// Send the message to the user `denny`
if(createForwardMessageRes.code == 0){
TencentImSDKPlugin.v2TIMManager.getMessageManager().sendMessage(id: createForwardMessageRes.data.id, receiver: "denny", groupID: "");
}