有时候为了需求,我们需要检测app版本更新今天在这里整合下

//获取当前版本号

NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];

CFShow((__bridge CFTypeRef)(infoDictionary));

NSString *app_Version = [infoDictionary objectForKey:@"CFBundleShortVersionString"];

//获取苹果商店的版本号

NSError  *error;

NSString * urlStr = [NSString stringWithFormat:@"http://itunes.apple.com/lookup?id=你要检测的app版本"];

NSURL * url =[NSURL URLWithString:urlStr];

NSURLRequest * request =[NSURLRequest requestWithURL:url];

NSData * response =[NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];

NSDictionary * appInfo =[NSJSONSerialization JSONObjectWithData:response options:NSJSONReadingMutableLeaves error:&error];

if (error) {

NSLog(@"error:%@",[error description]);

}

NSArray *resultsArray =[appInfo objectForKey:@"results"];

if (![resultsArray count]) {

NSLog( @"error: nil");

return self;

}

NSDictionary * infoDic =[resultsArray objectAtIndex:0];

NSString * appVersion = [infoDic objectForKey:@"version"];

appUrl =[infoDic objectForKey:@"trackViewUrl"];

double doucurrV =[app_Version doubleValue];

double  douappV= [appVersion doubleValue];

//判断版本号对比

if (doucurrV < douappV) {

NSString * titleStr =[NSString stringWithFormat:@"检查更新"];

NSString * message =[NSString stringWithFormat:@"发现新版本,是否更新?"];

UIAlertView * alert = [[UIAlertView alloc]initWithTitle:titleStr message:message delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];

alert.tag = 1001;

[alert show];

}else

{

UIAlertView * alert = [[UIAlertView alloc]initWithTitle:@"检测更新" message:@"无更新版本"delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];

alert.tag = 1002;

[alert show];

}

//跳转更新

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex

{

if (alertView.tag ==1001) {

if (buttonIndex == 1) {

[[UIApplication sharedApplication]openURL:[NSURL URLWithString: appUrl]];

}

}

}

iOS检测版本更新的更多相关文章

  1. iOS 检测版本更新(02)

    iOS 检测版本更新 如果我们要检测app版本的更新,那么我们必须获取当前运行app版本的版本信息和appstore 上发布的最新版本的信息. 当前运行版本信息可以通过info.plist文件中的bu ...

  2. iOS 检测版本更新

    如果我们要检测app版本的更新,那么我们必须获取当前运行app版本的版本信息和appstore 上发布的最新版本的信息. 当前运行版本信息可以通过info.plist文件中的bundle versio ...

  3. iOS子线程操作检测版本更新,有新版本通知用户更新, CheckVersion

    iOS子线程操作检测版本更新,有新版本通知用户更新 CheckVersion 一:如何使用: #import "CheckVersion.h" //输入你的app在appStore ...

  4. iOS开发 检测版本更新

    iOS开发 检测版本更新的实现 苹果给了我们一个接口,能根据应用id请求一些关于应用的信息.我们可以根据返回的信息,来判断版本是否和应用的版本一致,如果不一致,那么就出现新的版本了.这时,就需要向用户 ...

  5. 检测版本更新,iOS

    检测版本更新的方法. //检查新版本 更新 dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, ), ^ ...

  6. iOS检测用户截屏并获取所截图片

    iOS检测用户截屏并获取所截图片 微信可以检测到用户截屏行为(Home + Power),并在稍后点击附加功能按钮时询问用户是否要发送刚才截屏的图片,这个用户体验非常好.在iOS7之前, 如果用户截屏 ...

  7. iOS 检测文本中的 URL、电话号码等信息

    iOS 检测文本中的 URL.电话号码等信息 要检测文本中的 URL.电话号码等,除了用正则表达式,还可以用 NSDataDetector. 用 NSTextCheckingResult.Checki ...

  8. iOS自动检测版本更新

    虽然苹果官方是不允许应用自动检测更新,提示用户下载,因为苹果会提示你有多少个软件需要更新,但是有的时候提示用户一下有新版还是很有必要的. 首先说一下原理: 每个上架的苹果应用程序,都会有一个应用程序的 ...

  9. iOS - Harpy版本更新工具兼容版本第三方库

    Harpy(兼容版) git地址:https://github.com/yangchao0033/Harpy ###(iOS5-9适配版本,基于ArtSabintsev/Harpy v3.4.5) 提 ...

随机推荐

  1. 原创一看便知、Maven创建web项目

    创建maven-项目    如果 pom.xml 文件报错 右击项目-->Maven-->update Project 详细步骤   上图中Next 2.继续Next 3.选maven-a ...

  2. TomTom (16Q3)数据协议基础

    title: TomTom数据协议介绍 title: TomTom数据协议介绍TomTom公司介绍主要经营的业务TomTom数据特点数据内容概述数据表命名特点数据关联特点数据的基本信息 TomTom公 ...

  3. maven添加sqlserver的jdbc驱动包

    http://search.maven.org/中没有sqlserver的jdbc驱动,所以需要本地安装sqljdbc的jar包,然后再在pom里面引入 Step 1 在微软官网下载sqljdbc的j ...

  4. Virtualbox中不能为虚拟机打开一个新任务的原因及解决方法

    VirtualBox新建虚拟机时报错,不能为虚拟机打开一个新任务的原因 解决办法如下 1.保证bios里的virtualization technology的选项开启,不同电脑BIOS设置可能会不一样 ...

  5. c++ STL 学习记录 草稿。

    非常丑陋的尝试实现stl.慢慢修改吧. 1)简单实现 vector和list. 2)思索如何开始编写算法. 1,所有容器继承一个抽象容器.那么算法就可以使用抽象基类的next方法来遍历元素. 容器间耦 ...

  6. golang os/exec 执行外部命令

    exec包执行外部命令,它将os.StartProcess进行包装使得它更容易映射到stdin和stdout,并且利用pipe连接i/o. func LookPath(file string) (st ...

  7. Connection broken for id 62, my id = 70, error =

    启动费zokeeper失败,报错如下:Connection broken for id 62, my id = 70, error = 原因是因为zoo.cfg中server.id不正确. serve ...

  8. 编译2.4.X apache 常见错误

    安装高版本的 apr    apr-util ./configure prefix=/usr/local/apr   ./configure prefix=/usr/local/apr-util -- ...

  9. HTML5离线缓存

    参考文档:http://www.w3cschool.cc/html/html5-app-cache.html HTML5 应用程序缓存 又称离线缓存 ,即使断线了,刷新后也还是缓存了原来的页面,不会4 ...

  10. 鼠标hover某个元素时其属性表现Css transition 过渡效果(以宽高属性居中放大为例)

    <!DOCTYPE html> <html> <head> </head> <body id="body"> <! ...