Skip to main content

@Messages

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

Global IM UIKit does not implement the @all feature. The "@所有人" in the image is for design reference only. The data for the contact selection page needs to be provided by the application; otherwise, an empty list will be displayed. Before using the @ feature, please implement the group member provider.

alt(width=250)

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 implement the @all feature.
  • @Messages can be forwarded, but only as plain text without the @ feature.

Usage

Before using the @ feature, please implement the group member provider.

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 page to trigger message editing and mention (@) that user.

  • After entering the @ symbol in the conversation page, Global IM UIKit will navigate to the member list selection page. If the application does not implement the group member provider (GroupMembersProvider), this page will display an empty list. After implementing the group member provider (GroupMembersProvider), Global IM UIKit will obtain the group member data through the getGroupMembers method of the GroupMembersProvider object and display it in the list page.

    ConfigCenter.getUserInfoConfig().setGroupMembersProvider(new GroupMembersProvider() {
    @Override
    public void getGroupMembers(String groupId, Callback callback) {
    callback.onGetGroupMembersResult(UserInfoList);
    }
    });

Customization

Implementing @All

Global IM UIKit does not implement the page logic for the @all feature. You can implement it yourself.

  1. Create a new MentionedInfo and set MentionedType to MentionedType.ALL.

    String targetId = "Group Id";
    MentionedInfo mentionedInfo = new MentionedInfo(MentionedInfo.MentionedType.ALL, null, null);
  2. Set the MentionedInfo object in the MessageContent.

    TextMessage messageContent = TextMessage.obtain(content);
    messageContent.setMentionedInfo(mentionedInfo);
    Message message = Message.obtain(targetId, ConversationType.GROUP, textMessage);
  3. Call the sendMessage method of the Global IM UIKit core class RongCoreClient to send the message.

RongCoreClient.getInstance().sendMessage(message, null , null, new IRongCoreCallback.ISendMessageCallback(){
@Override
public void onAttached(Message message) {

}

@Override
public void onSuccess(Message message) {

}

@Override
public void onError(Message message, IRongCoreEnum.CoreErrorCode coreErrorCode) {

}
});