自己挖的坑自己要填上...iOS是只能自动提醒更新,界面上不能有按钮提供给用户手动更新的,自己失误在设置里面的版本号添加了点击手势来判断是否有新版本,然后就被拒了,所以要去掉手动更新的入口,只保留app启动或者首页的自动检查更新。
之前尝试过使用 http://itunes.apple.com/lookup?id=应用ID 来做搜索,但是不管用,上网查了之后使用 https://itunes.apple.com/lookup?id=应用ID 还是不行,最后使用了这种就
NSString *currentVersion = [NSBundle mainBundle].infoDictionary[@"CFBundleShortVersionString"];
WeakSelf(weakSelf)
[[ApiHelper shareInstance]getDataFromUrlWithGet:@"https://itunes.apple.com/cn/lookup?id=app应用id" params:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
StrongSelf(strongSelf)
NSMutableArray *result = [responseObject objectForKey:@"results"];
NSDictionary *dict = [result lastObject];
NSString *iTuneVersion = dict[@"version"];
strongSelf.appURL = dict[@"trackViewUrl"];
if (iTuneVersion == nil) {
[PracticalTools hudWithTitle:@"已经是最新版本了" andView:strongSelf.view andShowTime:1];
return ;
}
if ([currentVersion isEqualToString:iTuneVersion]) {
[PracticalTools hudWithTitle:@"已经是最新版本了" andView:strongSelf.view andShowTime:1];
}else{
[PracticalTools showAlertViewWithTitle:@"检查更新" message:@"发现新版本,是否更新" doneText:@"更新" cancelText:@"取消" doneHandle:^{
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:strongSelf.appURL]];
} cancelHandle:nil vc:self];
}
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
[PracticalTools hudWithTitle:@"获取失败" andView:weakSelf.view andShowTime:1];
}];
网友评论