sendC2CCustomMessage method
Implementation
Future<dynamic> sendC2CCustomMessage(Map<String, dynamic> params) async {
try {
final customParams = CreateMessage.createCustomMessage(
userID: params['userID'], customData: params['customData']);
final customMessage =
V2TIMManagerWeb.timWeb!.createCustomMessage(customParams);
final res = await wrappedPromiseToFuture(
V2TIMManagerWeb.timWeb!.sendMessage(customMessage));
final code = res.code;
if (code == 0) {
final message = jsToMap(res.data)['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());
}
}