app_upgrader 0.0.5 copy "app_upgrader: ^0.0.5" to clipboard
app_upgrader: ^0.0.5 copied to clipboard

a Flutter package designed to handle application upgrades seamlessly.

App Upgrader #

logo

Introduction #

App Upgrader is a Flutter package expertly crafted to manage application upgrades. It effortlessly addresses the challenges developers face while handling app updates. Our package is especially adept in scenarios involving phased rollouts in app stores. We proudly build upon the strong foundations laid by the new_version and in_app_update packages, and we extend our heartfelt gratitude to their contributors for their pioneering work.

🚀 Key Highlight: Smart Update Types? #

  • Force Update: When critical updates are necessary, App Upgrader ensures that users must update the app to continue its use. It's crucial for fixing security vulnerabilities or major bugs.
  • Flexible Update:: For less critical updates, App Upgrader allows users the choice to update at their convenience, enhancing user experience while still ensuring app freshness.
  • None:: This update type is designed for situations where no immediate action is required from the user.

🌟 Why Choose App Upgrader? #

  • Staged Deployment Compatibility: Seamlessly manage staged deployments. Our suite avoids the common problem of endless update cycles by intelligently handling different app versions offered in app stores.
  • Version History:: It allows the application to be updated according to the update types in the version history. For example, it checks the version date when updating an application that has not been updated for a long time even though the last version requires a flexible update. If there is a force update in intermediate versions, it is forced to force update. Thus, application security is maximised. (scenarios was inspired by bugragny. Thank you for your contributions!)
  • Local Testing Support: Unlike other packages, App Upgrader allows comprehensive local testing, streamlining your development and logging processes.

App Upgrader is your go-to solution for a hassle-free app update experience.

Getting Started #

To use App Upgrader, simply add it to your pubspec.yaml file:

dependencies:
  app_upgrader: ^latest_version

Then, import it in your Flutter app:

import 'package:app_upgrader/app_upgrader.dart';

Basic Usage #

Here's a quick example to get you started with App Upgrader:

AppUpgrader(
  versionInfoFetcher: MyVersionInfoFetcher(),
  bundleId: 'com.example.app',
  child: MyApp(),
)

Advanced Usage with go_router #

Integrating with navigation frameworks like go_router is straightforward:

GlobalKey<NavigatorState> navigatorKey = GlobalKey();

AppUpgrader(
  navigatorKey: navigatorKey,
  versionInfoFetcher: MyVersionInfoFetcher(),
  bundleId: 'com.example.app',
  child: MaterialApp.router(
    routerDelegate: _router.delegate(navigatorKey: navigatorKey),
    routeInformationParser: _router.defaultRouteParser(),
    // other MaterialApp.router parameters...
  ),
)

Documentation #

  • child: child is the widget located directly below AppUpgrader in the widget hierarchy. It's typically the root widget of your application, like MaterialApp or CupertinoApp.
AppUpgrader(
  child: MyApp(),
  // ...
)
  • navigatorKey: Used to integrate with MaterialApp.router for advanced navigation management.
GlobalKey<NavigatorState> navigatorKey = GlobalKey();
  • versionInfoFetcher: Defines an interface for fetching version information. Implement this class to customize how version information is fetched, for instance, from Firebase Remote Config or a custom backend. To use AppUpgrader, you need to provide version information from a service such as Firebase Remote Config or a custom backend service. This should include JSON data for both Android and iOS platforms under keys like android_version_info and ios_version_info.

Example JSON for Android (android_version_info):

{
  // key should be build number of Android App
  "210": {"update_type": "forceUpdate"},
  "205": {"update_type": "none"},
  // ... other versions ...
}

Example JSON for iOS (ios_version_info):

{
  // key should be version of iOS App
  "4.8.8": {"update_type": "forceUpdate"},
  "4.8.7": {"update_type": "none"},
  // ... other versions ...
}
class MyVersionInfoFetcher implements VersionInfoFetcher {
  late final FirebaseRemoteConfig firebaseRemoteConfig;

  @override
  Future<Map<String, dynamic>> fetchVersionInfo() {
    // Implement fetching logic here.
    // you can use your own service or firebase.
    // for example we use firebase remote config
    await firebaseRemoteConfig.fetchAndActivate();
    return jsonDecode(firebaseRemoteConfig.getString(
    Platform.isAndroid ? 'android_version_info' : 'ios_version_info'));
  }
}
  • bundleId: The unique identifier for your app, essential for fetching version information from app stores.
bundleId: 'com.example.myapp',
  • langCode: An optional parameter for specifying the language code when fetching app version information from the iOS App Store.
langCode: 'en', // English language
  • logger: An abstract class for logging purposes throughout the AppUpgrade process. Useful for debugging and testing, especially in local environments.
class MyAppUpgradeLogger implements AppUpgradeLogger {
  @override
  void log(String message) {
    // Logging logic here...
  }
}
  • showCustomUpdateDialog: A callback function that allows you to display a custom dialog for app updates. It is triggered when an update is detected, and you can tailor the dialog based on the type of update.
   showCustomUpdateDialog: (updateType, currentVersion, storeVersion) {
     // Different behavior based on update type
     switch (updateType) {
       case UpdateType.forceUpdate:
         // Force update: user must update the app
         showDialog(
           context: context,
           barrierDismissible: false, // User must take action
           builder: (BuildContext context) {
             return AlertDialog(
               title: Text('Mandatory Update'),
               content: Text(
                 'Version $storeVersion is available and is a mandatory update.'
               ),
               actions: <Widget>[
                 TextButton(
                   child: Text('Update Now'),
                   onPressed: () {
                     // Add your update action here
                   },
                 ),
               ],
             );
           },
         );
         break;
       case UpdateType.flexible:
         // Flexible update: user can choose to update now or later
         showDialog(
           context: context,
           barrierDismissible: true, // User can dismiss the dialog
           builder: (BuildContext context) {
             return AlertDialog(
               title: Text('New Update Available'),
               content: Text(
                 'Version $storeVersion is available. Would you like to update?'
               ),
               actions: <Widget>[
                 TextButton(
                   child: Text('Later'),
                   onPressed: () => Navigator.of(context).pop(),
                 ),
                 TextButton(
                   child: Text('Update Now'),
                   onPressed: () {
                     // Add your update action here
                   },
                 ),
               ],
             );
           },
         );
         break;
       default:
         // No update or another update type
         break;
     }
   }

  • isLocalTest: A flag to enable testing behaviors in local development. Set it to true for testing update processes without the need for publishing a new version.
isLocalTest: true,

Contributing #

Contributions to App Upgrader are welcome! Whether it's submitting bug reports, feature requests, or contributing to the code, we appreciate your effort to make App Upgrader better.

License #

App Upgrader is released under the BSD 3-Clause.


Happy Coding!

16
likes
0
points
43
downloads

Publisher

unverified uploader

Weekly Downloads

a Flutter package designed to handle application upgrades seamlessly.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

collection, flutter, html, http, in_app_update, package_info_plus, url_launcher

More

Packages that depend on app_upgrader