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 ...
随机推荐
- WordPress博客教程:博客赚钱
稍有关注独立博客的人都应该知道,中文博客实现盈利非常艰难,至少对于大部分中文博客来说是这样的.但很多时候我们不得不往赚钱的方向前进,至少要交得起域名和空间的租用费吧.不过期待赚钱前,你必须思考下如何提 ...
- Xamarin Visual Studio无法debug
在Visual Studio中,Target IOS Device下拉框是禁用状态,无法选择. Xamarin论坛中有不少关于这个问题的,如下面这个帖子: http://forums.xamarin. ...
- 奥迪--Q3
-型号:Q3 -价格:23-35W -动力:1.4T/2.0T -变速箱:6挡双离合/7挡双离合 -长宽高:4.40,1.84,1.59 -油箱:64L -发动机:EA888 -大灯:氙气(选装LED ...
- [转]如何编写和应用Java的自定义异常类
编写自定义异常类实际上是继承一个API标准异常类,用新定义的异常处理信息覆盖原有信息的过程.常用的编写自定义异常类的模式如下: public class CustomException exten ...
- CAS实践笔录
下载CAS 本文下载的是cas-server-4.0.0-release 下载地址: https://www.apereo.org/cas/download 导入Eclipse测试 Import -& ...
- 十 mybatis逆向工程
1 逆向工程 1.1 什么是逆向工程 mybaits需要程序员自己编写sql语句,mybatis官方提供逆向工程 可以针对单表自动生成mybatis执行所需要的代码(mapper. ...
- useful tools, excel import mysql,swagger
http://www.th7.cn/Program/java/201602/765943.shtml------swagger http://blog.csdn.net/csfreebird/arti ...
- 智能手机,医疗诊断,云会议(gotomeeting/citrix)
在诊断领域已出现很多大有希望的创新,它们可能会起到真正的变革作用. 例如,有一种新技术可以让健康护理工作者用一部智能手机拍摄高质量的视网膜图像.这些数码照片像素很高,足以帮助检测白内障.黄斑退化.糖尿 ...
- Java中对象构造
构造函数 作用:在构造对象的同时初始化对象.java强制要求对象 诞生同时被初始化,保证数据安全. 调用过程和机制:①申请内存,②执行构造函数的函数体,③返回对象的引用. 特点:与类同名,无返回类型, ...
- Best practice: escape, or encodeURI / encodeURIComponent
escape() Don't use it, as it has been deprecated since ECMAScript v3. encodeURI() Use encodeURI when ...