Skip to main content

Forward Messages

IMKit supports forwarding single messages, as well as sequential forwarding/combined forwarding of multiple messages, allowing users to forward messages from a chat UI to other conversations. The forwarded messages will appear in the message list component of the target conversation.

tip

By default, IMKit does not enable the combined forwarding feature. You can enable it as needed. In the screenshot below, the app has enabled combined forwarding, so both sequential forwarding and combined forwarding options are visible.

alt(width=250) alt(width=250)

Limitations

  • Not all message types support combined forwarding.
    • Supported message types: text, image, image-text, GIF, animated stickers (RC:StkMsg), business card, location, short video, file, standard voice, HD voice, and RTC call summary (RC:VCSummary).
    • Unsupported cases: Message types not listed above (e.g., quoted messages) and special cases like unsent messages cannot be forwarded. Custom messages do not support combined forwarding.

Usage

The forwarding feature is enabled by default in IMKit conversation pages. Users can long-press a message in the chat UI, select More from the pop-up menu, and then choose a forwarding option.

  • Sequential forwarding: Enabled by default. Allows forwarding one or multiple messages to a target conversation.
  • Combined forwarding: Disabled by default and hidden. If combined forwarding is selected, the SDK merges the selected messages into a single combined message containing the RCCombineMessage object (type identifier: RC:CombineMsg). Combined messages are displayed folded by default and can be expanded with a tap.

Enabling Combined Forwarding

IMKit supports combined forwarding, which is disabled by default. You can modify the global configuration to enable this feature.

RCKitConfigCenter.message.enableSendCombineMessage = YES;

Customization

Custom Forwarding Conversation List

In IMKit, after selecting sequential or combined forwarding, the forwarding conversation list page defaults to displaying the SDK's locally stored recent conversations.

If you need the SDK to navigate to a custom page for selecting conversations during forwarding, override the following method in RCConversationViewController. This allows you to present a custom conversation selection interface and pass the selected conversation array back to the IMKit SDK.

 @param index            0 for sequential forwarding, 1 for combined forwarding.
@param completedBlock Returns the list of target conversations for forwarding.

@discussion
Developers can override this method to present a custom conversation selection interface. After selection, call completedBlock with the selected conversations.
*/
- (void)forwardMessage:(NSInteger)index completed:(void (^)(NSArray<RCConversation *> *conversationList))completedBlock;
@end

For reference, see the implementation in RongCloud's SealTalk app. Details are in the forwardMessage method within RCDChatViewController.m.

- (void)forwardMessage:(NSInteger)index completed:(void (^)(NSArray<RCConversation *> *))completedBlock {
RCDForwardSelectedViewController *forwardSelectedVC = [[RCDForwardSelectedViewController alloc] init];
UINavigationController *navi = [[UINavigationController alloc] initWithRootViewController:forwardSelectedVC];
navi.modalPresentationStyle = UIModalPresentationFullScreen;
[forwardSelectedVC setSelectConversationCompleted:^(NSArray<RCConversation *> *_Nonnull conversationList) {
completedBlock(conversationList);
}];
[self.navigationController presentViewController:navi animated:YES completion:nil];
}