sendTransientMessage static method

dynamic sendTransientMessage(
  1. TransientMessage message,
  2. {required dynamic onSuccess(
      )?,
    1. required dynamic onError(
      1. CometChatException excep
      )?}
    )

    Transient messages are messages that are sent in real-time only

    method send transient message

    data A JSONObject to provide data.

    method could throw PlatformException with error codes specifying the cause

    Implementation

    static sendTransientMessage(TransientMessage message, {required Function()? onSuccess, required Function(CometChatException excep)? onError}) async {
      try {
        await channel.invokeMethod('sendTransientMessage', {
          'receiverId': message.receiverId,
          'receiverType': message.receiverType,
          'data': message.data,
        });
        if(onSuccess != null) onSuccess();
      } on PlatformException catch (platformException) {
        if(onError != null) onError(CometChatException(platformException.code, platformException.details, platformException.message));
      } catch (e) {
        debugPrint("Error: $e");
        if(onError != null) onError(CometChatException(ErrorCode.errorUnhandledException, e.toString() , e.toString()));
      }
    }