please select
  • UIKit
  • SDK
  • Server APIs
Chat/
SDK/
Unity(Game Solution)/
Message/
SDK
  • Run Demo
  • SDK Integration
  • Initialization
  • Login and Logout
  • Message
    • Message Overview
    • Sending Message
    • Receiving Message
    • Historical Message
    • Forwarding Message
    • Modifying Message
    • Deleting Message
    • Clearing Messages
    • Recalling Message
    • Online Message
    • Read Receipt
    • Querying Message
    • Group @ Message
    • Targeted Group Message
    • Notification Muting
    • Message Extension
  • Conversation
    • Conversation Overview
    • Conversation List
    • Getting Conversation
    • Conversation Unread Count
    • Pinning Conversation to the Top
    • Deleting Conversation
    • Conversation Draft
    • Conversation Mark
    • Conversation Group
  • Group
    • Group Overview
    • Group Management
    • Group Profile
    • Group Member Management
    • Group Member Profile
    • Custom Group Attribute
    • Group Counter
  • User
    • User Profile
    • User Status
    • Friend Management
    • Friend List
    • Blocklist
  • Changelog
  • Guideline for Beginners
  • Console Guide
    • Creating and Upgrading an Application
    • Basic Configuration
    • Feature Configuration
    • Account Management
    • Group Management
    • Webhook Configuration
  • Product Introduction
    • Message Management
      • One-to-One Message
      • Message Storage
      • Offline Push
      • Group Message
      • Message Formats
    • Account System
      • Login Authentication
      • Online Status Management
    • Group Related
      • Group System
      • Group Management
    • User Profile and Relationship Chain
      • Profile Management
      • Relationship Chain Management
  • Purchase Guide
    • Billing Overview
    • Pricing
  • Error Codes

Group @ Message

Overview

The sender listens for the characters in the input box. When the sender enters @, the group member selection UI will pop up. After the target group members are selected, the message will be displayed in the input box in the format of "@A @B @C......", which can be further edited before sent. In the group chat list of the receiver's conversation UI, the identifier "someone@me" or "@ all" will be displayed to remind the user that the user was mentioned by someone in the group chat.
Note:
Currently, only text @ messages are supported.

Sending a Group @ Message

1. The sender listens for the text input box on the chat UI and launches the group member selection UI. After group members are selected, the ID and nickname information of the members is called back. The ID is used to create the Message object, while the nickname is to be displayed in the text box.
2. The sender calls the MsgSendMessage API (details) to create a text @ message, create the Message message object, specify the target group members, and send the message object.
Sample code:
// Create a group @ message
var message = new Message
{
message_conv_id = conv_id,
message_conv_type = TIMConvType.kTIMConv_Group,
message_elem_array = new List<Elem>{new Elem
{
elem_type = TIMElemType.kTIMElem_Text,
text_elem_content = Input.text
}},
| message_group_at_user_array | UserID list of users that need to be mentioned (@) in the group message. To @all, pass in the `kImSDK_MesssageAtALL` field. |
};
StringBuilder messageId = new StringBuilder(128);
TIMResult res = TencentIMSDK.MsgSendMessage(conv_id, TIMConvType.kTIMConv_Group, message, messageId, (int code, string desc, string json_param, string user_data)=>{
// Async message sending result
});

Receiving a Group @ Message

1. When the conversation is loaded and updated, call the conv_group_at_info_array API (details) of ConvInfo to get the @ data list of the conversation.
2. Call the conv_group_at_info_at_type API (details) of the GroupAtInfo object in the list to get the @ data type and update it to the @ information of the current conversation.
Sample code:
TIMResult res = TencentIMSDK.ConvGetConvList((int code, string desc, List<ConvInfo> info_list, string user_data)=>{
foreach (ConvInfo info in info_list)
{
foreach (GroupAtInfo at_info in info.conv_group_at_info_array)
{
if (at_info.conv_group_at_info_at_type == TIMGroupAtType.kTIMGroup_At_Me) {
// @me
}
if (at_info.conv_group_at_info_at_type == TIMGroupAtType.kTIMGroup_At_All) {
// @all in the group
}
if (at_info.conv_group_at_info_at_type == TIMGroupAtType.kTIMGroup_At_All_At_ME) {
// @all in the group and @me alone
}
}
}
});