sendGroupCustomMessage method

Future sendGroupCustomMessage(
  1. Map<String, dynamic> params
)

Implementation

Future<dynamic> sendGroupCustomMessage(Map<String, dynamic> params) async {
  try {
    final customParams = CreateMessage.createCustomMessage(
        userID: params['groupID'],
        customData: params['customData'],
        convType: 'GROUP',
        priority: params['priority']);
    final textMessage =
        V2TIMManagerWeb.timWeb!.createCustomMessage(customParams);
    final res = await wrappedPromiseToFuture(
        V2TIMManagerWeb.timWeb!.sendMessage(textMessage));
    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());
  }
}