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 ...
随机推荐
- [读书笔记]项目管理实战:Microsoft Project精髓与方法
<项目管理实战:Microsoft Project精髓与方法>是Bonnie Biafore 写的一本书.Bonnie Biafore 作为项目管理师(PMP),她有20余年为大中小型客户 ...
- PHP+jQuery 注册模块的改进之一:验证码存入SESSION
/* ******* Date:2014-09-28 ******* Author:小dee ******* Blog:http://www.cnblogs.com/dee0912/*/ 对上一篇博文 ...
- 连接别人创建的ORACLE数据库
以oracle10g版本为例,本机必须安装oralce10g的客户端或oralce10g的服务器 方法一(从服务器配置): 第一步:打开配置和移植工具-->Net Manager 第二步:选中服 ...
- MySQL并发调优和IO调优
一.myisam的IO调优1.myisam通常在每次写入后把索引的改变刷写到磁盘上.所以批处理通常会更快点.做到这点,可以通过LOCK TABLES,他可以把写入控制到对表解锁.还可以用delay_k ...
- 如何删除docker images/containers
docker images往往不知不觉就占满了硬盘空间,为了清理冗余的image,可采用以下方法: 1.进入root权限 sudo su 2.停止所有的container,这样才能够删除其中的imag ...
- C# 如何读取一行中的所有变量
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...
- android studio无法关联源码
1.查看源码的时候报这个, 说找不到API 23的源码 2.本地的SDK 3.google stackoverflow 给出解决方案 http://stackoverflow.com/questio ...
- 【iTerm2】美化你的Terminal 赠佛祖像
我们开发就是喜欢各种酷炫的东西,对于有洁癖的我,连命令行都不放过了 先上图看效果,命令行显示高亮部分 实现过程: 第一步:.bash_prompt脚本 # ~/.bash_prompt # This ...
- ::after,::before使用
::after,::before使用 1.:before 选择器在被选元素的内容前面插入内容. 请使用 content 属性来指定要插入的内容. <!DOCTYPE html> < ...
- 防止sql注入,过滤敏感关键字
//sql过滤关键字 public static bool CheckKeyWord(string sWord) { //过滤关键字 string StrKeyWord = @"select ...