checkForUpdates static method

Future<AppVersionResult> checkForUpdates({
  1. String? appleId,
  2. String? playStoreId,
  3. String? country = 'us',
})

Checks for app update in stores, taking into account the local version.

  • appleId unique identifier in Apple Store, if null, we will use your package name.
  • playStoreId unique identifier in Play Store, if null, we will use your package name.
  • country, region of store, if null, we will use 'us'.

example

await AppVersionUpdate.checkForUpdates(
  appleId: '123456789',
  playStoreId: 'com.example.app',
  country: 'br')
.then((data) async {
   if (data.canUpdate!) {
      //action...
    });

Implementation

static Future<AppVersionResult> checkForUpdates({
  String? appleId,
  String? playStoreId,
  String? country = 'us',
}) async {
  AppVersionData data = await fetchVersion(
      playStoreId: playStoreId, appleId: appleId, country: country);

  return AppVersionResult(
      canUpdate: data.canUpdate,
      storeUrl: data.storeUrl,
      storeVersion: data.storeVersion,
      platform: data.targetPlatform);
}