背景
IOS18场景下无法点击更新程序按钮,点击后无效果
经过各种排查之后发现:
BUG IN CLIENT OF UIKIT: The caller of UIApplication.openURL(_:) needs to migrate to the non-deprecated UIApplication.open(_:options:completionHandler:). Force returning false (NO).
好吧,UIApplication.openURL(_:) 已经被废弃了,需要更新成新的方式
更正
原
-(void)openAppStore:(NSString *)iOSUrl{
NSString *url = [iOSUrl stringByAddingPercentEncodingWithAllowedCharacters:[[NSCharacterSet characterSetWithCharactersInString:@""] invertedSet]];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];
}新
-(void)openAppStore:(NSString *)iOSUrl {
// 对URL进行编码
NSString *encodedUrl = [iOSUrl stringByAddingPercentEncodingWithAllowedCharacters:[[NSCharacterSet characterSetWithCharactersInString:@""] invertedSet]];
// 将 NSString 转换为 NSURL
NSURL *url = [NSURL URLWithString:encodedUrl];
// 检查是否可以打开该 URL
if ([[UIApplication sharedApplication] canOpenURL:url]) {
// 打开 URL
[[UIApplication sharedApplication] openURL:url options:@{} completionHandler:^(BOOL success) {
if (success) {
NSLog(@"Successfully opened the URL.");
} else {
NSLog(@"Failed to open the URL.");
}
}];
} else {
NSLog(@"Cannot open the URL.");
}
}开源项目
我用的项目是:https://github.com/azhon/flutter_app_update
提交了issues并且被合并了,但是用它更新后的版本与我本地有依赖冲突,所以我自己改了一个版本
https://github.com/almightyYantao/flutter_app_update
flutter_app_update:
git:
url: https://github.com/almightyYantao/flutter_app_update
作者的情感表达细腻入微,让人在阅读中找到了心灵的慰藉。
?情感共鸣类?
这篇文章如同一幅色彩斑斓的画卷,每一笔都充满了独特的创意。