sendMessage method

  1. @override
Future<void> sendMessage({
  1. required MessageParams messageParams,
  2. required dynamic callback(
    1. FlyResponse response
    ),
})
override

This method is used to send the message with message params type.

Implementation

@override
Future<void> sendMessage(
    {required MessageParams messageParams,
    required Function(FlyResponse response) callback}) async {
  LogMessage.d("sendMessage", messageParams.toMap());
  //sendMessage
  String? messageResponse;
  try {
    messageResponse = await mirrorFlyMethodChannel.invokeMethod(
        'sendMessage', messageParams.toMap());
    var res = convertChatMessageJsonFromString(messageResponse);
    callback.call(FlyResponse(true, res, "message send successfully"));
  } on PlatformException catch (e) {
    LogMessage.d("Platform Exception =", " $e");
    callback.call(FlyResponse(false, FlyConstants.empty, FlyConstants.empty,
        FlyException(e.code, e.message, e.details)));
  } on Exception catch (e) {
    LogMessage.d("Exception ", " $e");
    callback.call(FlyResponse(false, FlyConstants.empty, FlyConstants.empty,
        FlyException(FlyErrorCode.unHandle, FlyErrorMessage.unHandle, e)));
  }
}