getMessageReceipts static method

Future<List<MessageReceipt>?> getMessageReceipts(
  1. int messageId, {
  2. required dynamic onSuccess(
    1. List<MessageReceipt> messageReceipt
    )?,
  3. required dynamic onError(
    1. CometChatException excep
    )?,
})

Method to get message receipts.

method could throw PlatformException with error codes specifying the cause

Implementation

static Future<List<MessageReceipt>?> getMessageReceipts(int messageId,
    {required Function(List<MessageReceipt> messageReceipt)? onSuccess,
    required Function(CometChatException excep)? onError}) async {
  try {
    List<MessageReceipt> receiptList = [];
    final result =
        await channel.invokeMethod('getMessageReceipts', {'id': messageId});
    for (var _obj in result) {
      try {
        receiptList.add(MessageReceipt.fromMap(_obj));
      } catch (e) {
        _errorCallbackHandler(null, null, e, onError);
        return [];
      }
    }
    if (onSuccess != null) onSuccess(receiptList);
    return receiptList;
  } on PlatformException catch (p) {
    _errorCallbackHandler(null, p, null, onError);
  } catch (e) {
    _errorCallbackHandler(null, null, e, onError);
  }
  return null;
}