launch method
Future<bool>
launch({
- required UpgradeOpenType type,
- String? packageName,
- String? appleID,
override
跳转至应用商店
type 目标页面类型,参见 UpgradeOpenType
packageName 目标应用包名,可不传;不传时 Android 默认使用本应用包名;iOS 不使用该参数
appleID App 的 Apple ID,iOS 必传,Android 不使用该参数
获取方式:App Store Connect(https://appstoreconnect.apple.com)→ 我的 App → 选择对应 App → 「App 信息」中的「Apple ID」;
也可从 App Store 链接 https://apps.apple.com/app/id<AppleID> 中 id 后的数字部分获取
返回是否成功发起跳转;iOS 端由系统回调给出,Android 端以能否唤起目标页面为准(不含用户后续操作)
Implementation
@override
Future<bool> launch({required UpgradeOpenType type, String? packageName, String? appleID}) async {
return switch (defaultTargetPlatform) {
.android => _launchOnAndroid(type: type, packageName: packageName),
.iOS => _launchAppStore(type: type, id: appleID),
_ => throw UnsupportedError(
'Opening the ${type.name} page is not supported on $defaultTargetPlatform. '
'Only ${type == .reviews ? 'iOS is' : 'Android and iOS are'} currently supported by upgrade_util.',
),
};
}