handleReceivedMessage method

  1. @override
Future<void> handleReceivedMessage(
  1. Map notificationData,
  2. dynamic callback(
    1. FlyResponse response
    )?
)
override

This method is used to handle the FCM Push Notification Payload.

Implementation

@override
Future<void> handleReceivedMessage(
    Map notificationData, Function(FlyResponse response)? callback) async {
  String? res;
  try {
    res = await mirrorFlyMethodChannel.invokeMethod(
        'handleReceivedMessage', {"notificationdata": notificationData});
    callback?.call(FlyResponse(
        true, convertChatMessageJsonFromString(res), FlyConstants.empty));
    // return convertChatMessageJsonFromString(res);
  } 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)));
  }
}