createTextMessage
功能介绍
创建文本消息
参数详解
参数名称 |
参数类型 |
是否必填 |
描述 |
text |
string |
是 |
消息文本 |
返回模板
V2TimValueCallback<V2TimMsgCreateInfoResult>
{
code: number,
desc: string,
data: {
id: string,
messageInfo: V2TimMessage,
}
}
返回值详解
代码示例
import { TencentImSDKPlugin } from 'react-native-tim-js';
const createTextMessageRes = await TencentImSDKPlugin.v2TIMManager
.getMessageManager()
.createTextMessage(
'test'
);
if (createTextMessageRes.code === 0) {
const id = createTextMessageRes.data?.id;
const sendMessageRes = await TencentImSDKPlugin.v2TIMManager
.getMessageManager()
.sendMessage({ id: id!, receiver: 'userID', groupID: 'groupID' });
if (sendMessageRes.code === 0) {
}
}