getMessageReceipts static method
Future<List<MessageReceipt> ?>
getMessageReceipts(
- int messageId, {
- required dynamic onSuccess(
- List<
MessageReceipt> messageReceipt
- List<
- required dynamic onError(
- 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) {
if(onError != null) onError(CometChatException(ErrorCode.errorUnhandledException, e.toString() , e.toString()));
return [];
}
}
if(onSuccess != null) onSuccess(receiptList);
return receiptList;
} 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()));
}
return null;
}