Forwarding Messages
Global IM UIKit supports forwarding a single message, as well as sequential forwarding and combined forwarding of multiple messages. Users can forward messages from the chat UI to other conversations. After forwarding, the messages will appear in the message list component of the target conversation page.
Combined forwarding is disabled by default in Global IM UIKit. You can enable it as needed.
Limitations
- Not all message types support sequential forwarding.
- Supported message types for sequential forwarding: text, voice, short video, image, file, graphic-text, sticker (
RC:StkMsg
), location, merged, and quoted messages. - Unsupported cases: Message types not in the supported list, as well as special cases such as unsent messages, cannot be forwarded.
- Supported message types for sequential forwarding: text, voice, short video, image, file, graphic-text, sticker (
- Not all message types support combined forwarding.
- Supported message types: text, image, GIF, sticker (
RC:StkMsg
), short video, file, standard voice, high-definition voice, and merged forwarding messages. - Unsupported cases: Message types not in the supported list, such as business cards, location, graphic-text, quoted messages, gray bar (
RC:InfoNtf
), command reminder messages (RC:CmdNtf
), and special cases like unsent messages, cannot be forwarded. Custom messages do not support combined forwarding.
- Supported message types: text, image, GIF, sticker (
- Combined forwarding supports merging up to 100 messages.
Usage
Forwarding is enabled by default in the Global IM UIKit conversation page. Users can long-press a message in the conversation page, select More in the pop-up menu, and then choose the forwarding option.
Sequential Forwarding
Sequential Forwarding: Enabled by default. Users can forward a single or multiple messages to a target conversation. The callback for sequential forwarding is forwardMessageByStep()
in ChatFragment
. Override this method to navigate to the conversation selection page. After selecting the target conversation, send the messages based on the selected conversation type. Example code:
// Load conversation list and select a conversation page (example)
ChatListViewModel chatListViewModel = new ViewModelProvider(this).get(ChatListViewModel.class);
mChatListComponent.setPagedDataLoader(chatListViewModel);
chatListViewModel.init();
chatListViewModel.getChatListLiveData().observe(this, baseChatModels -> mChatListComponent.setChatListData(baseChatModels));
// Send messages to the selected conversation (example)
for (Message message : messageList) {
MessageContent messageContent = message.getContent();
if (messageContent != null) {
messageContent.setUserInfo(null);
// If it's a mention message, cancel the mention
if (messageContent.getMentionedInfo() != null) {
messageContent.setMentionedInfo(null);
}
}
MessageContent messageContent = message.getContent();
boolean isImageMessageRemoteUriEmpty = messageContent instanceof ImageMessage && ((ImageMessage) messageContent).getRemoteUri() == null;
boolean isGifMessageRemoteUriEmpty = messageContent instanceof GIFMessage && ((GIFMessage) messageContent).getRemoteUri() == null;
boolean isMediaMessageRemoteUriEmpty = messageContent instanceof MediaMessageContent && (((MediaMessageContent) messageContent).getMediaUrl() == null || TextUtils.isEmpty(((MediaMessageContent) messageContent).getMediaUrl().toString()));
if (isImageMessageRemoteUriEmpty || isGifMessageRemoteUriEmpty || isMediaMessageRemoteUriEmpty) {
RongCoreClient.getInstance().sendMediaMessage();
} else {
RongCoreClient.getInstance().sendMessage();
}
}
Combined Forwarding
Combined Forwarding: Enabled by default. For combined forwarding, the SDK merges the selected messages into a single combined forwarding message, which includes the message content object CombineV2Message
(type identifier: RC:CombineV2Msg
). The combined message is displayed in a collapsed state by default and can be expanded by clicking. The callback for combined forwarding is forwardMessageByCombine()
in ChatFragment
. Override this method to navigate to the conversation selection page. After selecting the target conversation, call the ViewModel
's onSendCombineMessage()
to forward the combined message. Example code:
// Load conversation list and select a conversation page (example)
ChatListViewModel chatListViewModel = new ViewModelProvider(this).get(ChatListViewModel.class);
mChatListComponent.setPagedDataLoader(chatListViewModel);
chatListViewModel.init();
chatListViewModel.getChatListLiveData().observe(this, baseChatModels -> mChatListComponent.setChatListData(baseChatModels));
// Send messages to the selected conversation (example)
getViewModel().getMessageSender().onSendCombineMessage(conversationIdentifier, messages);