createTargetedGroupMessage
Introduction
Create a target group message.
A targeted group message is a message sent to specified members in a group, which cannot be received by other group members.
For details, you can referring to this document.
Parameter details
Parameter name | Parameter type | Required | Description |
---|---|---|---|
id | string | yes | The local id of the created message. |
receiverList | string[] | yes | The list of user ID of several members in the group. |
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 target group message created. |
Code example
import { TencentImSDKPlugin } from 'react-native-tim-js';
const target = await TencentImSDKPlugin.v2TIMManager
.getMessageManager()
.createTextMessage('');
const id = target.data?.id;
const groupTarget = await TencentImSDKPlugin.v2TIMManager
.getMessageManager()
.createTargetedGroupMessage(
id!,
['user1', 'user2']
);
if (groupTarget.code === 0) {
const groupTargetdId = groupTarget.data?.id;
const sendMessageRes = await TencentImSDKPlugin.v2TIMManager
.getMessageManager()
.sendMessage({
id: groupTargetdId!,
receiver: 'userID',
groupID: 'groupID',
});
if (sendMessageRes.code === 0) {
}
}