Keep track of app versions and prompt users to update the app whenever there are new updates available.
This packages provides a simple yet customisable way to suggest or force updates to Android & iOS apps. Built on top of the in_app_update package for Android and upgrader for iOS.
The package also leverages the version_tracker plugin to track the app versions accross updates.
- Retrieve information about available updates from the Play Store or App Store.
- Version bomb. Force users to update the app if the update is mandatory by configuring a minimum version using your custom Backend or Firebase Remote Config.
- Launch Android updates using the native In-App Updates flows, supporting flexible and immediate updates.
- Request iOS updates by redirecting the user to the App Store.
- Track version update history and launches to trigger onboarding flows, database migrations, and more.
View the example project for a complete working example.
Add the following dependency to your pubspec.yaml
file:
dependencies:
app_versioning: latest
-
Initialize the
AppVersioning
class with your app's identifiers and minimum version provider. You can use one of the following factories or create your own implementation of the AppVersioning interface:- Use the
apiService
factory to retrieve the versioning from your backend.
final appVersioning = AppVersioning.apiService( apiConfig: ApiConfig( endpoints: ApiVersioningEndpoints( "https://api.example.org", minimumVersioningEndpoint: "api/api-compatibility", ), ), updateConfig: UpdateConfig( appStoreAppId: "1234567890", playStoreAppId: "org.example.versioning", appstoreCountryCode: "US", ), );
- Use the
firebaseService
factory to retrieve the versioning from Firebase Remote Config.
final appVersioning = AppVersioning.firebaseService( remoteConfigKeys: const RemoteConfigKeys( minimumIosVersionKey: "minimumIosVersion", minimumAndroidVersionKey: "minimumAndroidVersion", ), updateConfig: const UpdateConfig( appStoreAppId: "1234567890", playStoreAppId: "org.example.versioning", appstoreCountryCode: 'US', ), );
- Use the
-
Track the current version when the app is launched.
await appVersioning.tracker.track();
-
Check whether a new update is available.
final appUpdateInfo = await appVersioning.getAppUpdateInfo();
-
If an update is available, prompt the user to update the app using your own UI elements.
if (appUpdateInfo.isUpdateAvailable) { switch (appUpdateInfo.updateType) { case AppUpdateType.Optional: _showUpdatePopup(forceUpdate: false); break; case AppUpdateType.Mandatory: _showUpdatePopup(forceUpdate: true); break; } }
-
If the user accepts the update, or the update is mandatory, launch the update flow.
appVersioning.launchUpdate(updateInBackground: true);
Apps using a version below the minimum version will be forced to update with a mandatory update type. This plugin currently supports 2 different backends to set the minimum version supported on the app.
- API: An arbitrary URL endpoint that returns the minimum versions JSON.
- Firebase Remote Config: Key/value pairs with the minimum versions specified on Firebase.
This requires the project to include and set up Firebase separately. You can import the configuration using the remote_config.json file.
Check the CONTRIBUTING.md guide for more information.
- Set the new version on the pubspec.yaml
version
field. - Update the CHANGELOG.md file documenting the changes.
- Update the README.md file if necessary.
- Run
dart pub publish --dry-run
to ensure the package can be published successfully. - Create a new tag with the release version
git tag -a x.y.z -m "x.y.z" && git push --tags
. - Navigate to GitHub Releases and create a new release for the previously created tag, including the CHANGELOG.md changes.
- Finally run
dart pub publish
to deploy the project.
- upgrader - Copyright (c) 2018-2022, Larry Aasen MIT License for providing the iOS update mechanisms.
- in_app_update - Copyright (c) 2020 Victor Choueiri MIT License for providing the Android update mechanisms.
- version_tracker - Copyright (c) 2021 Kevin Morelli MIT License for providing the code to track version accross updates.
This repo is covered under the MIT License.