new_version_plus 包帮助 Flutter 应用通过检查应用商店或 Google Play 的元数据来确定用户是否正在运行最新版本。它支持 Android、iOS、macOS、Windows 和 Linux 等多个平台,非常适合跨设备管理应用更新。该包从官方商店获取版本信息,并在有更新可用时通知用户,从而提高用户留存率,并确保用户能够访问最新的功能和安全补丁。
适合场景
提示用户在有新版本可用时进行更新
在应用启动时检查更新
与应用内更新对话框集成
监控企业应用的版本合规性
支持跨平台更新检查
主要特点
跨平台支持(Android、iOS、macOS、Windows、Linux)
从应用商店获取版本信息
版本比较的简单 API
可配置的更新检查频率
内置通知处理
适合对象
需要自动更新检测的应用程序
需要版本控制的企业应用
针对多个操作系统的应用
寻求最小化设置以进行更新检查的开发者
具有严格版本控制策略的项目
使用建议
需要互联网连接以检查版本
可能需要针对非商店分发进行定制
仅限官方应用商店版本数据
不适用于离线优先的应用程序
依赖外部API,这些API可能有速率限制
原始 README
以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。
☕ Support Me
If you find this plugin useful, please consider supporting me:
Note
Original repository: https://pub.dev/packages/new_version
The problem with the original repository is that it will no longer be maintained by the creator, for this reason this repository was created in order to maintain updated code and make respective improvements as long as it is required.
New Version Plus Plugin 🎉
A Flutter plugin that makes it possible to:
Check if a user has the most recent version of your app installed.
Show the user an alert with a link to the appropriate app store page.
In main.dart (or wherever your app is initialized), create an instance of NewVersionPlus.
final newVersionPlus = NewVersionPlus();
The plugin will automatically use your Flutter package identifier to check the app store. If your app has a different identifier in the Google Play Store or Apple App Store, you can overwrite this by providing values for androidId and/or iOSId.
For iOS: If your app is only available outside the U.S. App Store, you will need to set iOSAppStoreCountry to the two-letter country code of the store you want to search. See http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2 for a list of ISO Country Codes.
You can then use the plugin in two ways.
Quickstart
Calling showAlertIfNecessary with your app's BuildContext will check if the app can be updated, and will automatically display a platform-specific alert that the user can use to go to the app store.
If you want to create a custom alert or use the app version information differently, call getVersionStatus. This will return a Future<VersionStatus> with information about the local and app store versions of the app.
final status = await newVersionPlus.getVersionStatus();
status.canUpdate // (true)
status.localVersion // (1.2.1)
status.storeVersion // (1.2.3)
status.appStoreLink // (https://itunes.apple.com/us/app/google/id284815942?mt=8)
If you want to present a customized dialog, you can pass your VersionStatus to showUpdateDialog().