yx_app_upgrade_flutter/lib/models/app_upgrade_version.dart

73 lines
2.0 KiB
Dart
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import 'app_market.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多渠道更新)
/// 配置后,只允许跳转到白名单中且设备已安装的应用市场
/// 如果设备上没有白名单中的任何应用市场,将提示用户选择其他更新方式
final List<AppMarket>? 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, 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';
}
}