Skip to main content

@Message

Mentions (@) are a common feature in group chat conversations, allowing users to mention specific users or all group members within a conversation to enhance the notification effect of messages. When using the @ feature, the message content will additionally carry the RCMentionedInfo object. Global IM UIKit enables the @ feature by default.

Limitations

  • Only supported in group chat conversations.
  • Global IM UIKit only implements the @ feature when sending text messages or quoted messages by default.
  • Global IM UIKit does not support the @all feature.
  • @Messages can be forwarded, but the forwarded content is plain text and no longer retains the @ feature.

Usage

Before using the @ feature, implement RCIMGroupMemberDataSource and set the group member list information proxy for Global IM UIKit. For details, see User Information.

Global IM UIKit enables the @ feature by default in the configuration. The usage is as follows:

  • Long-press a user's avatar in the conversation UI to trigger message editing and mention (@) that user.
  • After entering the @ symbol in the conversation UI, Global IM UIKit will pop up a member list selection page. If the application has not set the group member list information proxy, this page will display an empty list. Once the group member list information proxy is set, Global IM UIKit will retrieve the group member data through the getAllMembersOfGroup method of the RCIMGroupMemberDataSource protocol and display it in the pop-up.

Customization

Custom Member Selection Interface

If you want to replace the member selection interface, you can override the following method to pop up a custom member selection interface. After the selection is completed, call the selectedBlock to pass in the selected user list.

- (void)inputTextViewDidInputMention:(UITextView *)textView;

After the selection is completed, call the following method to pass in the selected user list:

[self.inputBar.textView insertMentionedUser:user];

Implementing @All

Global IM UIKit does not implement the page logic for the @all feature. You can implement it yourself. You need to construct an RCMentionedInfo object with the type property set to RC_Mentioned_All and write it into the message content. After constructing the RCMessage, use the sendMessage (for regular messages) or sendMediaMessage method to send it to the conversation.

RCTextMessage *txtMsg = [RCTextMessage messageWithContent:@"Test text message"];

RCMentionedInfo *mentionedInfo = [[RCMentionedInfo alloc] initWithMentionedType:RC_Mentioned_All userIdList:nil mentionedContent:nil];
txtMsg.mentionedInfo = mentionedInfo;

RCMessage *message = [[RCMessage alloc]
initWithType:ConversationType_PRIVATE
targetId:@"targetId"
direction:MessageDirection_SEND
content:txtMsg];

[[RCCoreClient sharedCoreClient] sendMessage:message pushContent:nil pushData:nil attached:^(RCMessage * _Nullable message) {

} successBlock:^(RCMessage * _Nonnull successMessage) {

} errorBlock:^(RCErrorCode nErrorCode, RCMessage * _Nonnull errorMessage) {

}];