createTextAtMessage
Introduction
Create a group @ message.
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.
For details, you can referring to this document.
Parameter details
Parameter name | Parameter type | Required | Description |
---|---|---|---|
text | string | yes | The text of the message. |
atUserList | string[] | yes | The constant value __kImSDK_MesssageAtALL__ can be speficied to the atUserList, to mention all members (@all) in the group, shows in the following example codes. |
Returned template
V2TimValueCallback<V2TimMsgCreateInfoResult>
{
code: number,
desc: string,
data: {
id: string,
messageInfo: V2TimMessage,
}
}
Return value details
name | type | description |
---|---|---|
code | number | Request result: Error codes. 0 means success. |
desc | string | The description of the error. It will be empty if success. |
data | V2TimMsgCreateInfoResult | The group at message created. |
Code example
import { TencentImSDKPlugin } from 'react-native-tim-js';
const createTextAtMessageRes = await TencentImSDKPlugin.v2TIMManager
.getMessageManager()
.createTextAtMessage(
'test',
['__kImSDK_MesssageAtALL__', 'uesr1']
);
if (createTextAtMessageRes.code === 0) {
const id = createTextAtMessageRes.data?.id;
const sendMessageRes = await TencentImSDKPlugin.v2TIMManager
.getMessageManager()
.sendMessage({ id: id!, receiver: '', groupID: 'groupID' });
if (sendMessageRes.code === 0) {
}
}