sendC2CTextMessage method
Implementation
Future<V2TimValueCallback<V2TimMessage>> sendC2CTextMessage(
Map<String, dynamic> params) async {
try {
final textParams = CreateMessage.createTextMessage(
userID: params['userID'], text: params['text']);
final textMessage = V2TIMManagerWeb.timWeb!.createTextMessage(textParams);
final res = await wrappedPromiseToFuture(
V2TIMManagerWeb.timWeb!.sendMessage(textMessage));
final code = res.code;
if (code == 0) {
final message = jsToMap(res.data)["message"];
log(message);
final formatedMessage =
await V2TIMMessage.convertMessageFromWebToDart(message);
return CommonUtils.returnSuccess<V2TimMessage>(formatedMessage);
} else {
return CommonUtils.returnErrorForValueCb<V2TimMessage>("发送文本消息失败");
}
} catch (error) {
return CommonUtils.returnErrorForValueCb<V2TimMessage>(error.toString());
}
}