Giter Site home page Giter Site logo

infinum / flutter-prince-of-versions Goto Github PK

View Code? Open in Web Editor NEW
6.0 6.0 0.0 284 KB

Library used for easier versioning of your applications, allowing you to prompt your users to update the app to the newest version

Home Page: https://pub.dev/packages/flutter_prince_of_versions

License: MIT License

Kotlin 24.96% Ruby 5.87% Swift 24.19% Objective-C 0.10% Dart 44.88%
version-control version testflight open-source flutter

flutter-prince-of-versions's Introduction

Flutter Prince of Versions

PoV

Library checks for updates using configuration from some resource.

It uses:

Usage

Use this library when you want to check if the new version of your application is available and do something with that information (prompt user to update the application).

Getting all the remote data

final data = await FlutterPrinceOfVersions.checkForUpdates(
  url: url,
  shouldPinCertificates: false,
  requestOptions: {
    'region': (String region) {
      return region == 'hr';
    }
  },
);
print('Update status: ${data.status.toString()}');
print('Current version: ${data.version.major}');
print('Last available major version: ${data.updateInfo.lastVersionAvailable.major}');

With fetching all the remote data, you have the flexiblity of creating a custom flow regarding the updates. For example you can always update the app when a new minor version is available.

Automatic check with data from the App Store

If you don't want to manage the JSON configuration file required by above mentioned methods, you can use checkForUpdatesFromAppStore. This method will automatically get your app BundleID and it will return version info fetched from the App Store.

However, updateStatus result can only assume values UpdateStatus.noUpdateAvailable and UpdateStatus.newUpdateAvailable. It is not possible to check if update is mandatory by using this method and data provided by the App Store.

Automatic check with data from Google Play

For checking updates on Google Play use checkForUpdatesFromGooglePlay. This method will automatically check Google Play and prompt user about a new version. Whenever a status of the update is changed, your callback methods will be triggered.

final Callback callback = MyCallback(context);
await FlutterPrinceOfVersions.checkForUpdatesFromGooglePlay('Google Play url', callback);
class MyCallback extends Callback {
  MyCallback(BuildContext context) {
    _context = context;
  }
  BuildContext _context;

  @override
  void error(String localizedMessage) {
    showDialog<bool>(
      context: _context,
      builder: (BuildContext context) {
        return CupertinoAlertDialog(
          title: Text('An error occurred'),
          content: Text('$localizedMessage'),
          actions: <Widget>[
            CupertinoDialogAction(
              child: Text('Ok'),
              isDestructiveAction: false,
              onPressed: () => Navigator.pop(context, true),
            ),
          ],
        );
      },
    );
  }
}

In this example, we created a class and implemented an error method. When checkForUpdatesFromGooglePlay triggers an error method, an alert dialog will show.

R8 / ProGuard

If you are using R8 or ProGuard add the options from this file.

JSON file formatting

For JSON file details and formatting, read JSON specification.

iOS example

{
   "ios":{
      "minimum_version":"1.2.3",
      "minimum_version_min_sdk":"8.0.0",
      "latest_version":{
         "version":"2.4.5",
         "notification_type":"ALWAYS",
         "min_sdk":"12.1.2"
      }
   },
   "ios2":[
      {
         "required_version":"1.2.3",
         "last_version_available":"1.9.0",
         "notify_last_version_frequency":"ALWAYS",
         "requirements":{
            "required_os_version":"8.0.0",
            "region":"hr",
            "bluetooth":"5.0"
         },
         "meta":{
            "key1":"value1",
            "key2":2
         }
      },
      {
         "required_version":"1.2.3",
         "last_version_available":"2.4.5",
         "notify_last_version_frequency":"ALWAYS",
         "requirements":{
            "required_os_version":"12.1.2"
         },
         "meta":{
            "key3":"value3",
         }
      }
   ],
   "meta":{
      "key3":true,
      "key4":"value2"
   }
}

Android example

{
	"android": [{
		"required_version": 10,
		"last_version_available":12,
		"notify_last_version_frequency":"ONCE",
		"requirements":{
		   "required_os_version":18
		},
		"meta":{
		   "key1":"value3"
		}
	},{
		"required_version": 10,
		"last_version_available":13,
		"notify_last_version_frequency":"ONCE",
		"requirements":{
		   "required_os_version":19
		},
		"meta":{
		   "key2":"value4"
		}
	}],
	"meta": {
		"key1": "value1",
		"key2": "value2"
	}
}

Contributing

Feedback and code contributions are very much welcome. Just make a pull request with a short description of your changes.

Credits

flutter-prince-of-versions's People

Contributors

dundo7 avatar itsjokr avatar khaleelsh avatar zenled avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

flutter-prince-of-versions's Issues

Object is not abstract and does not implement abstract member public abstract fun error

Unable to use the plugin with the latest Flutter 3.

e: /Users/saileshbro/.pub-cache/hosted/pub.dartlang.org/flutter_prince_of_versions-2.0.1/android/src/main/kotlin/com/example/flutter_prince_of_versions/FlutterPrinceOfVersionsPlugin.kt: (117, 79): Object is not abstract and does not implement abstract member public abstract fun error(p0: String, p1: String?, p2: Any?): Unit defined in io.flutter.plugin.common.MethodChannel.Result
e: /Users/saileshbro/.pub-cache/hosted/pub.dartlang.org/flutter_prince_of_versions-2.0.1/android/src/main/kotlin/com/example/flutter_prince_of_versions/FlutterPrinceOfVersionsPlugin.kt: (121, 33): 'error' overrides nothing
2

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':flutter_prince_of_versions:compileDebugKotlin'.
> A failure occurred while executing org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction
   > Compilation error. See log for more details

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 11s
Exception: Gradle task assembleDevDebug failed with exit code 1

FlutterPrinceOfVersions.checkForUpdatesFromGooglePlay <asynchronous suspension>

Hi
I try to use this package to check for updates from play store but i get this error
FlutterPrinceOfVersions.checkForUpdatesFromGooglePlay (package:flutter_prince_of_versions/src/flutter_prince_of_versions.dart:65:5)
E/flutter ( 5217):
here is my code

void initState()  {
    super.initState();
    DateTime now = new DateTime.now();
  DateTime date = new DateTime(now.year, now.month, now.day);
  print(date);
  update();
  }
Future<void> update() async{
  final Callback callback = MyCallback(context);
  await FlutterPrinceOfVersions.checkForUpdatesFromGooglePlay('https://play.google.com/store/apps/details?id=com.focus.ebook.FocusEbook', callback);

}

and i am using your callback class without any modifications .

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.