markAsDelivered static method

dynamic markAsDelivered(
  1. BaseMessage message, {
  2. required dynamic onSuccess(
    1. String message
    )?,
  3. required dynamic onError(
    1. CometChatException excep
    )?,
})

Mark the messages for a particular conversation as delivered .

method could throw PlatformException with error codes specifying the cause

Implementation

static markAsDelivered(BaseMessage message, {required Function(String message)? onSuccess, required Function(CometChatException excep)? onError}) async {
  try {
    Map<String, dynamic> messageMap = message.toJson();
    final result = await channel.invokeMethod('markAsDelivered', {'baseMessage': messageMap});
    if(onSuccess != null) onSuccess(result);
  } 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()));
  }
}