74 lines
2.1 KiB
Dart
74 lines
2.1 KiB
Dart
import 'app_upgrade_method.dart';
|
||
|
||
/// 应用升级版本信息(由服务器返回的数据模型)
|
||
/// 用户只需返回此类的实例,插件会自动获取当前App版本进行比对
|
||
class AppUpgradeVersion {
|
||
/// 版本名称 (如 "1.0.0")
|
||
final String? versionName;
|
||
|
||
/// 版本号 (如 10)
|
||
final int? versionBuildNumber;
|
||
|
||
/// 更新内容
|
||
final String updateContent;
|
||
|
||
/// 下载地址 (Android APK下载地址)
|
||
final String? downloadUrl;
|
||
|
||
/// 是否强制更新
|
||
final bool isForce;
|
||
|
||
/// App Store地址 (iOS)
|
||
final String? appStoreUrl;
|
||
|
||
/// APK文件大小 (字节)
|
||
final int? apkSize;
|
||
|
||
/// APK文件的MD5值 (用于校验)
|
||
final String? apkMd5;
|
||
|
||
/// Android 应用市场服务商列表 (用于控制 market 更新入口是否可点击)
|
||
///
|
||
/// 后端推荐返回大写字符串,如 ["XIAOMI", "HUAWEI", "HONOR", "TENCENT"]。
|
||
/// SDK 会兼容大小写,并将 REDMI/POCO 归一为 XIAOMI,iQOO 归一为 VIVO。
|
||
/// null 表示跳过校验;空数组表示 market 更新方式置灰不可点击。
|
||
final List<String>? appMarkets;
|
||
|
||
/// 支持的更新方式 (如果为null,默认使用所有可用的方式)
|
||
final List<AppUpgradeMethod>? supportedMethods;
|
||
|
||
AppUpgradeVersion({
|
||
required this.updateContent,
|
||
this.versionName,
|
||
this.versionBuildNumber,
|
||
this.downloadUrl,
|
||
this.isForce = false,
|
||
this.appStoreUrl,
|
||
this.apkSize,
|
||
this.apkMd5,
|
||
this.appMarkets,
|
||
this.supportedMethods,
|
||
});
|
||
|
||
@override
|
||
String toString() {
|
||
return 'AppUpgradeVersion(versionName: $versionName, versionBuildNumber: $versionBuildNumber, isForce: $isForce, downloadUrl: $downloadUrl, appMarkets: $appMarkets, supportedMethods: $supportedMethods)';
|
||
}
|
||
|
||
/// 获取App Store地址
|
||
/// [id] App ID
|
||
/// 返回 App Store地址
|
||
/// itms-apps://itunes.apple.com/app/id1656489561
|
||
static String getAppStoreByItunes(String id) {
|
||
return 'itms-apps://itunes.apple.com/app/id$id';
|
||
}
|
||
|
||
/// 获取App Store地址
|
||
/// [id] App ID
|
||
/// 返回 App Store地址
|
||
/// https://apps.apple.com/cn/app/id1656489561
|
||
static String getAppStoreByUrl(String id) {
|
||
return 'https://apps.apple.com/cn/app/$id';
|
||
}
|
||
}
|