GithubHelp home page GithubHelp logo

version_check's Introduction

version_check

pub package

Check iOS/Android/Mac store app version and provide update alert if neccessary.

Usage

import 'package:version_check/version_check.dart';

  final versionCheck = VersionCheck();

  @override
  void initState() {
    super.initState();
    checkVersion();
  }

  Future checkVersion() async {
    await versionCheck.checkVersion(context);
  }

version_check's People

Contributors

mix1009 avatar monfadev avatar saulopef avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

version_check's Issues

Unhandled Exception: PlatformException(Error, Error while launching https://apps.apple.com/de/app/snapchat/id447188370?uo=4, null, null)

Hello,

I created an update window and I used snapchat as test app to force an update. Im developing on an iPhone 14 simulator running iOS 16.2. Im getting Unhandled Exception: PlatformException(Error, Error while launching https://apps.apple.com/de/app/snapchat/id447188370?uo=4, null, null) when clicking the update button, but the link is correct. Below is the code im using leaving out the UI part which is not relevant:

 String? version = '';
  String? storeVersion = '';
  String? storeUrl = '';
  String? packageName = '';

  final versionCheck = VersionCheck(
    packageName: Platform.isIOS
        ? 'com.toyopagroup.picaboo'
        : '',
    packageVersion: '12.0.0',
    showUpdateDialog: customShowUpdateDialog,
    country: 'DE',
  );

  

 Future checkVersion() async {
    await versionCheck.checkVersion(context);
    setState(() {
      version = versionCheck.packageVersion;
      packageName = versionCheck.packageName;
      storeVersion = versionCheck.storeVersion;
      storeUrl = versionCheck.storeUrl;
    });

    print(version);
     print(packageName);
      print(storeVersion);
       print(storeUrl);
  }

@override
  void initState() {
    super.initState();
    checkVersion();
  }

the print outputs:

flutter: 12.0.0
flutter: com.toyopagroup.picaboo
flutter: 12.20.0.32
flutter: https://apps.apple.com/de/app/snapchat/id447188370?uo=4

[VERBOSE-2:dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(Error, Error while launching https://apps.apple.com/de/app/snapchat/id447188370?uo=4, null, null)
#0      StandardMethodCodec.decodeEnvelope
message_codecs.dart:653
#1      MethodChannel._invokeMethod
platform_channel.dart:296
<asynchronous suspension>
#2      VersionCheck.launchStore
version_check.dart:98
<asynchronous suspension>
#3      customShowUpdateDialog.<anonymous closure>.<anonymous closure>
app_wrapper.dart:149
<asynchronous suspension>

Play store updated the UI

We can not get the version using '.hAyfc.BgcNfc' according to the new UI of the Google Play Store. Hotfix needed.

PlayStore and AppStore version different when checking

_shouldUpdate function when I try to get the storeVersion it is different:

  • Android from PlayStore: 1.0.0 (without build number)
  • iOS from AppStore: 1.0.0+1 (with build number)

Whenever iOS version checking it is always return hasUpdate true. Example:

Current version is 1.0.1
Store version is 1.0.1+2

  final arr1 = packageVersion!.split('.');
  final arr2 = storeVersion!.split('.');

 arr1[0]: 1
 arr2[0]: 1
 arr2 > arr1: 1 > 1

 arr1[1]: 0
 arr2[1]: 0
 arr2 > arr1: 0 > 0

 arr1[2]: 1
 arr2[2]: 1+2
 arr2 > arr1: 1+2 > 1       // This part always return true

Current solution for me is like this:

If Android put version number
If iOS put version number + build number
PackageInfo info = await PackageInfo.fromPlatform();
final versionCheck = VersionCheck(
      packageName: com.example.test,
      packageVersion: Platform.isAndroid
          ? info.version
          : '${info.version}+${info.buildNumber}',
      showUpdateDialog: (c, v) {
        showDialog();
      },
    )

Any other better solution for this? Thanks

Publish package

I think it's time to publish using the latest update sir.

flutter pub publish --dry-run
flutter pub publish

Update package

Are you going to update the package? The http package is currently at version ^1.1.0 and we can't update it because it causes an error.
Great package anyway.

Unhandled Exception: RangeError (index)

RangeError encountered while running on IOS device.
Need to pass additional "country" parameter in _getIOSStoreVersionAndUrl, should be "bundleId" and "country" parameters.

version_check_ios_issue

Version comparison is incorrect

Given a package version of 3.1.0 and a store version of 3.0.68 the dialog is opening. This should not be the case since the package version has a larger minor version than the store version.

See example with version comparison function of this package. I'd suggest using something like https://pub.dev/packages/version for semver version comparison.

import 'dart:math' as math;

void main() {
  print(_shouldUpdate('3.1.0', '3.0.68')); // prints true
}


bool _shouldUpdate(String? packageVersion, String? storeVersion) {
  if (packageVersion == storeVersion) return false;

  final arr1 = packageVersion!.split('.');
  final arr2 = storeVersion!.split('.');

  for (int i = 0; i < math.min(arr1.length, arr2.length); i++) {
    int? v1 = int.tryParse(arr1[i]);
    int? v2 = int.tryParse(arr2[i]);

    if (v1 == null || v2 == null) {
      if (arr2[i].compareTo(arr1[i]) > 0) {
        return true;
      }
    } else if (v2 > v1) {
      return true;
    }
  }

  return false;
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.