SDKsAndroid
Create a mention message
Use createTextAtMessage to create a text message that mentions group members.
Construct a text message with @ mentions targeting specific group members, with optional quoting of a previous message. When delivered, recipient clients display high-priority mention notifications and badges in the conversation list.
Code example
String text = "@Alex Please review the latest proposal";
List<String> userIDs = Collections.singletonList("user_alex");
AtUserInfo atUserInfo = new AtUserInfo();
atUserInfo.setAtUserID("user_alex");
atUserInfo.setGroupNickname("Alex");
List<AtUserInfo> atUserInfos = Collections.singletonList(atUserInfo);
Message quoteMessage = null; // Pass an existing Message object to quote-reply, or null
Message message = OpenIMClient.getInstance().messageManager.createTextAtMessage(
text,
userIDs,
atUserInfos,
quoteMessage
);Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
text | String | Yes | The complete text of the message, including @ mention labels. |
userIDs | List<String> | Yes | List of user IDs of the mentioned group members (deduplicated). |
atUserInfos | List<AtUserInfo> | Yes | List of user details corresponding to userIDs, containing display names and identifiers. |
quoteMessage | Message | No | Optional reference to a previous message to quote-reply. Pass null if not quoting. |
Return value
Returns the newly initialized Message object ready for transmission.
State changes after the call
- Local initialization: Initializes the local
Messagestructure without sending data to the server. - Sending to the group: Mention messages are typically used in group conversations. Call Send a message passing the target group ID (
recvGid).
Was this page helpful?