checkIOSUpdate method

Future<bool> checkIOSUpdate(
  1. Map<String, dynamic> iosData,
  2. PackageInfo packageInfo,
  3. bool allowSkip,
  4. BuildContext context,
  5. DownloadState downloadState,
  6. UpdateCenterConfig config,
  7. String downloadUrl,
)

Checks for an available update for iOS platform and shows update dialog if necessary.

Implementation

Future<bool> checkIOSUpdate(
  Map<String, dynamic> iosData,
  PackageInfo packageInfo,
  bool allowSkip,
  BuildContext context,
  DownloadState downloadState,
  UpdateCenterConfig config,
  String downloadUrl, // This value is not used in the iOS model
) async {
  IOSModel model = IOSModel(
    iosData['versionName'],
    iosData['changeLog'],
    iosData['sourceUrl'],
    iosData['versionCode'],
    iosData['minSupport'],
  );

  int buildNumber = int.parse(packageInfo.buildNumber);

  if (model.minSupport > buildNumber) {
    allowSkip = false; // Update is mandatory
  }

  // Check if the current build number is less than the update version code
  if (buildNumber < model.versionCode) {
    if (context.mounted && config.globalConfig.iosDialogBuilder != null) {
      await config.globalConfig.iosDialogBuilder!(
          context,
          model, // Assume this is your AndroidModel instance with update info
          config,
          downloadState, // Your DownloadState instance
          allowSkip);
    }

    return true; // Return true to indicate that an update is available
  }

  if (buildNumber >= model.versionCode) {
    if (config.globalConfig.isNoUpdateAvailableToast && config.globalConfig.iosNoUpdateAvailableBuilder != null) {
      config.globalConfig.iosNoUpdateAvailableBuilder?.call(context);
    }
    return false;
  }
  return false; // No update available
}