iOS添加自动更新的代码
- (void)versionUpdate{
//获得当前发布的版本
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, ), ^{
//耗时的操作--获取某个应用在AppStore上的信息,更改id就行
__weak LoginViewController *weakSelf = self;
NSString *string = [NSString stringWithContentsOfURL:[NSURL URLWithString:@"http://itunes.apple.com/cn/lookup?id=1108288793"] encoding:NSUTF8StringEncoding error:nil];
NSData *data = [string dataUsingEncoding:NSUTF8StringEncoding];
NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableLeaves error:nil];
NSString *version = [[[dic objectForKey:@"results"]firstObject]objectForKey:@"version"];
NSString *updateInfo = [[[dic objectForKey:@"results"]firstObject]objectForKey:@"releaseNotes"];
//NSString *updateURL = [[[dic valueForKey:@"results"] firstObject] objectForKey:@""];
//获得当前版本
NSString *currentVersion = [[[NSBundle mainBundle]infoDictionary]objectForKey:@"CFBundleShortVersionString"];
dispatch_async(dispatch_get_main_queue(), ^{
//更新界面
if ( version &&![version isEqualToString:currentVersion]) {
//有新版本
NSString *message = [NSString stringWithFormat:@"有新版本发布啦!\n%@",updateInfo];
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"温馨提示" message:message preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *action1 = [UIAlertAction actionWithTitle:@"忽略" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
}];
UIAlertAction *action2 = [UIAlertAction actionWithTitle:@"前往更新" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
NSString *url = @"https://itunes.apple.com/cn/app/rich-products/id1108288793?mt=8&uo=4";
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];
}];
[alertController addAction:action1];
[alertController addAction:action2];
[weakSelf presentViewController:alertController animated:YES completion:nil];
}else{
//已是最高版本
NSLog(@"已是最高版本");
}
});
});
}
记得http://itunes.apple.com/cn/lookup?id=1108288793,这中间的这个CN不能掉了,不然返回的JSON数组为空。
iOS添加自动更新的代码的更多相关文章
- 后盾网lavarel视频项目---phpstorm 配置ftp, 自动更新同步代码
后盾网lavarel视频项目---phpstorm 配置ftp, 自动更新同步代码 一.总结 一句话总结: 1.在phpstorm中设置:路径Tools/Deployment/Configuratio ...
- iOS 关于自动更新的分阶段发布(灰度发布)的相关简介
前言: AppStore 发布应用方式除了自动和手动,如今添加了分阶段发布(灰度发布).目的很明确,降低新版本骤然上升的bug率,不能挽回,只能发布新版本的风险.也也是针对禁止使用热修复,推出的相对 ...
- Git github webhook 自动更新/部署代码 php自动更新脚本
这几天尝试了利用github的webhook,当代码更新到github,我们的测试服务器自动更新最新的gitbub仓库代码. 先列几个大概步骤,有时间再补充详细 1 . 服务器生成ssh key,一般 ...
- svn自动更新网站代码
运行环境说明:svn的执行目录: /usr/bin/svnsvn版本库目录: /usr/local/nginx/html/svnrepos/coinhello (其中svnrepos是我各个项目版本库 ...
- 如何屏蔽 iOS 软件自动更新,去除更新通知和标记
适用于 iOS.iPadOS 和 watchOS,即 iPhone.iPad 和 Apple Watch 通用. 请访问原文链接:https://sysin.org/article/Disable-i ...
- 关闭iOS的自动更新
Safari打开网址https://oldcat.me/web/NOOTA9.mobileconfig,安装描述文件,就不会自动下载和提示更新最新的iOS了
- ios关闭自动更新
iPhone系统更新超级烦人,避免测试机升级的方法 1. 设置禁用网络 设置-网线局域网-使用WLAN与蜂窝移动网的应用,将设置项设置为关闭 2. 一劳永逸,安装证书, 证书https://oldca ...
- git自动更新网站代码
1.实现过程在linux上安装git服务.创建源版本库.从源版本库克隆得到网站目录,然后利用git中的hooks机制,在git push推送代码到源版本库的时候,触发编写的shell脚本,更新网站目录 ...
- springboot项目自动更新修改代码工具
在pom.xml配置文件加入以下依赖,代码修改就不需要重启了. <dependency> <groupId>org.springframework.boot</group ...
随机推荐
- PHP 设计模式 笔记与总结(4)PHP 链式操作的实现
PHP 链式操作的实现 $db->where()->limit()->order(); 在 Common 下创建 Database.php. 链式操作最核心的地方在于:在方法的最后 ...
- PHP获取某远程网站的服务器时间
<?php function get_time($server){ $data = "HEAD / HTTP/1.1\r\n"; $data .= "Host: ...
- PHP程序员必须清楚的问题汇总
PHP程序员必须清楚的问题汇总 投稿:hebedich 字体:[增加 减小] 类型:转载 这篇文章主要介绍了PHP程序员必须清楚的问题汇总,需要的朋友可以参考下 你是否正在准备寻找一份PH ...
- 20145225 实验四《Andoid开发基础》
实验内容 搭建Android环境 运行Android 修改代码,能输出学号 实验步骤 安装Android Studio 安装Android的SDK 运行Andriod Studio并在模拟手机上显示自 ...
- 类库引用EF
安装EntityFramework 添加引用system.data.entity;
- nginx服务器安装与启动
nginx服务器介绍 1.nginx服务器功能 nginx服务器可以扮演:轻量级的web服务器.应用服务器.代理服务器.反向代理服务器.后台服务器.CDN缓存服务器 nginx的基本模块: 内核模块C ...
- github中non-fast-forward错误的解决
参考文献 1.http://www.linuxidc.com/Linux/2012-04/58985.htm 2.http://ihower.tw/blog/archives/2620 3.http: ...
- 1 2 3 n
n(n+1)/2 连续自然数 1,2,3.....,n 队列 从中任意取出1至n个相加,可以表示的连续自然数队列中最大的自然数是多少 受"高斯求和--蛇头蛇尾脑图--长方形对角线脑图--苯环 ...
- 获取真实ip的报告
今天登录九秒社团 http://www.9miao.com/的时候忘记了用户名和密码,尝试了5次都没登录成功,网站弹出提示15分钟后才能再次登录.我纳闷它是怎么判断用户的登录次数,这时候用户还没有登录 ...
- pdo封装类
<?php //http://www.imavex.com/php-pdo-wrapper-class/ class db extends PDO { private $error; priva ...