Skip to main content

Forward Messages

Global IM UIKit supports forwarding a single message, as well as forwarding multiple messages individually or merging and forwarding multiple messages. This feature allows users to 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.

Merge Forwarding is not enabled by default in Global IM UIKit. You can enable it as needed. In the image below, the app has enabled the merge forwarding feature, so both Forward Individually and Merge and Forward options are visible.

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

Limitations

  • Not all message types support individual forwarding.
    • Supported message types for individual forwarding: text, voice, short video, image, file, graphic, sticker (RC:StkMsg), location, merged, and quoted messages.
    • Unsupported cases: Message types not in the supported list, as well as special cases like messages that failed to send, cannot be forwarded.
  • Not all message types support merge forwarding.
    • Supported message types: text, image, GIF, sticker (RC:StkMsg), short video, file, standard voice, high-definition voice, and merged messages.
    • Unsupported cases: Message types not in the supported list, such as business cards, location, graphic, quoted messages, gray bar (RC:InfoNtf), command reminder messages (RC:CmdNtf), as well as special cases like messages that failed to send, cannot be forwarded. Custom messages are not supported for merge forwarding.
  • Merge forwarding supports merging up to 100 messages.
  • The conversation selection page for forwarding needs to be implemented at the application layer, and then the interface is called to send the messages.

Usage

Users can long-press a message in the conversation page, click Select in the pop-up box, and the forwarding options will be displayed.

Forward Individually

The callback for clicking Forward Individually is -forwardOriginalMessages:. Override this method, navigate to the conversation selection page, and after selecting, call the viewModel's -forwardMessages:messageModels:combine: to forward the messages. Example code is as follows:

/// Callback for clicking Forward Individually
- (void)forwardOriginalMessages:(NSArray *)messageModels {
/// Conversation selection page
TestForwardSelectionViewController *controller = [[TestForwardSelectionViewController alloc] init];
controller.chatModels = self.recentChatModels;
__weak typeof(self) weakSelf = self;
controller.selectionResult = ^(NSArray *models) {
/// Forward messages individually after selection
[weakSelf.viewModel forwardMessages:messageModels toChats:models combine:NO];
/// End the message selection state in the conversation page
[weakSelf endSelection];
};
UINavigationController *navigation = [[UINavigationController alloc] initWithRootViewController:controller];
navigation.modalPresentationStyle = UIModalPresentationOverFullScreen;
navigation.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
[self presentViewController:navigation animated:YES completion:NULL];
}

Merge and Forward

The callback for clicking Merge and Forward is -forwardCombinedMessages:. Override this method, navigate to the conversation selection page, and after selecting, call the viewModel's -forwardMessages:messageModels:combine: to forward the messages. Example code is as follows:

/// Callback for clicking Merge and Forward
- (void)forwardCombinedMessages:(NSArray *)messageModels {
/// Conversation selection page
TestForwardSelectionViewController *controller = [[TestForwardSelectionViewController alloc] init];
controller.chatModels = self.recentChatModels;
__weak typeof(self) weakSelf = self;
controller.selectionResult = ^(NSArray *models) {
/// Merge and forward after selection
[weakSelf.viewModel forwardMessages:messageModels toChats:models combine:YES];
/// End the message selection state in the conversation page
[weakSelf endSelection];
};
UINavigationController *navigation = [[UINavigationController alloc] initWithRootViewController:controller];
navigation.modalPresentationStyle = UIModalPresentationOverFullScreen;
navigation.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
[self presentViewController:navigation animated:YES completion:NULL];
}