checkAndUpdateAlert method

  1. @override
Future<void> checkAndUpdateAlert(
  1. BuildContext context
)
override

Implementation

@override
Future<void> checkAndUpdateAlert(BuildContext context) async {
  // if (true) {
  final response = await methodChannel
      .invokeMapMethod<String, dynamic>("checkAndUpdateAlert");

  ///The value returned from the Native SDK is in the form of a Map<String, dynamic>?.
  if (response != null) {
    if (response['category'] == 1) {
      /*
        mapOf<String, Any>(
          "updateid" to updateData.updateId,
          "currentversion" to updateData.currentVersion,
          "featureTitle" to updateData.featureTitle,
          "features" to updateData.features,
          "remindMeLaterText" to updateData.remindMeLaterText,
          "updateNowText" to updateData.updateNowText,
          "neverAgainText" to updateData.neverAgainText,
          "option" to updateData.option,
          "reminderDays" to updateData.reminderDays,
          "forceInDays" to updateData.forceInDays,
          "alertType" to updateData.alertType,
          "customStoreUrl" to updateData.customStoreUrl,
          "category" to 1
      )*/

      final map = Map<String, dynamic>.from(response.cast<String, dynamic>());
      final updateData = AppUpdateData.fromJson(map);
      Future.delayed(
          Duration.zero,
          () => AppticsInAppUpdateAlert.show(
              context: context,
              appUpdateData: updateData,
              onClickUpdate: onClickUpdate,
              onClickReminder: onClickReminder,
              onClickIgnore: onClickIgnore));
      onSendImpressionStatus(updateData.updateId);
    } else if (response['category'] == 2) {
      /*
        mapOf<String, Any>(
              "title" to appticsAppUpdateNotSupported.title,
              "description" to appticsAppUpdateNotSupported.description,
              "continueBtTxt" to appticsAppUpdateNotSupported.continueBtTxt,
              "alertType" to appticsAppUpdateNotSupported.alertType,
              "updateId" to appticsAppUpdateNotSupported.updateId,
              "category" to 2
          )
          */

      final map = Map<String, dynamic>.from(response.cast<String, dynamic>());
      final updateData = AppticsAppUpdateNotSupported.fromJson(map);
      Future.delayed(
          Duration.zero,
          () => AppticsInAppUpdateAlert.showNonSupportAlert(
              context: context,
              appUpdateData: updateData,
              onClick: onClickNonSupportAlert));
      onSendImpressionStatus(updateData.updateId);
    }
  }
  // }
}