美文网首页
iOS 版本更新

iOS 版本更新

作者: 雪丹妮_66865 | 来源:发表于2018-09-30 16:57 被阅读8次
  1. 获取本机版本号

NSDictionary *localDic = [[NSBundle mainBundle] infoDictionary];
NSString *localVersions = [localDic objectForKey:@"CFBundleShortVersionString"];

  1. 查看appstore中的软件最新版本

地址:https://itunes.apple.com/lookup?id=软件的apple Id

NSArray *resultArr = responseObject[@"results"];
NSDictionary *resultDic = resultArr.firstObject;
NSString *latestVersion = resultDic[@"version"];

  1. 如果版本不一致,进行更新

if ([latestVersion compare:localVersions options:NSNumericSearch] == NSOrderedDescending) {
[self updateBtnActionwithLatestVersion:latestVersion];
}

  • (void)updateBtnActionwithLatestVersion:(NSString *)latestVersion {
    UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"检查到最新版本" message:latestVersion preferredStyle:UIAlertControllerStyleAlert];
    UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {

    }];
    UIAlertAction *updateAction = [UIAlertAction actionWithTitle:@"下载" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
    UIApplication *application = [UIApplication sharedApplication];
    [application openURL:[NSURL URLWithString:@"https://itunes.apple.com/cn/app/id软件的Apple id"]];
    }];
    [alertController addAction:cancelAction];
    [alertController addAction:updateAction];
    [self presentViewController:alertController animated:YES completion:nil];
    }

相关文章

  • iOS版本更新

    iOS APP版本 更新

  • iOS 上传AppStore 被拒汇总

    (1)、苹果要求版本更新必须使用iOS版本更新内置更新机制。 4. Design: Preamble Design...

  • iOS版本更新

    1、获取当前版本 NSString *current_version = [[[NSBundle mainBund...

  • iOS 版本更新

    获取本机版本号 NSDictionary *localDic = [[NSBundle mainBundle] i...

  • iOS版本更新

    版本更新 #pragma mark -检查版本更新 - (void)checkNewVersion { // NS...

  • iOS 版本更新

    众所周知苹果拒绝任何带有版本更新的提示出现在页面中,因此我们通过接口获取,处理是否显示更新提示。 1.判断版本号 ...

  • iOS 版本更新

    1.获取本地版本信息 2.获取App Store版本信息 3.新旧版本对比 代码: 请求的基类中获取App Sto...

  • iOS版本更新

    最近,应项目需求,简单写了一个版本更新的提示,有需要的码友可以去下载看看,实现起来比较简单。 效果图 首先是请求a...

  • iOS版本更新

    一、获取app线上版本苹果提供网址:https://itunes.apple.com/lookup网址所需参数:i...

  • iOS 版本更新

    今天公司要给APP加上“检查更新”这个服务,因为在上一家公司做过,所以没花太多时间就完成了。不过还是看以前公司的代...

网友评论

      本文标题:iOS 版本更新

      本文链接:https://www.haomeiwen.com/subject/wcwwoftx.html