有时候为了需求,我们需要检测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. build/envsetup.sh 生成的命令详解表

    参考: https://wiki.cyanogenmod.org/w/Envsetup_help 它是一个.sh文件,用source后就生成android编译相关函数,具体如下. 速查 Invokin ...

  2. webpack的简单使用

    今天简单的说一下webpack的使用. 打开cmd(也可以用别的看个人爱好) 打开你要创建项目的文件夹: webpack安装: 1.全局安装webpack:$npm install webpack - ...

  3. ASP.NET中的文件操作(文件信息,新建,移动,复制,重命名,上传,遍历)(亲测详细)

    做了几天的文件操作,现在来总结一下,错误之处,还望指点!以文件为例,如果对文件夹操作,基本上将File换为Directory即可(例:FileInfo file = new FileInfo(Path ...

  4. c++并发练习---多线程顺序打印

    参考:http://blog.csdn.net/liuxuejiang158blog/article/details/22061267 题目:编写一个程序,开启3个线程,这3个线程的ID分别为A.B. ...

  5. EL表达式语言总结

    EL介绍 Expressive Language, JSP2.0引入,简化jsp开发中对对象的引用. 基本语法 ${表达式} 常见用法 根据其访问对象,可大体分成三类:访问数据及其各种表达式,访问EL ...

  6. rabbitmq 3.6 延时消息

    rabbitmq-plugins enable rabbitmq_delayed_message_exchange #安装插件 https://github.com/rabbitmq/rabbitmq ...

  7. jxl_1

    import java.io.File; import jxl.CellView; import jxl.Workbook; import jxl.format.Alignment; import j ...

  8. window 配置wnmp(转下整理 ,全)

    工具/原料   RunHiddenConsole.exe 下载地址:http://pan.baidu.com/share/link?shareid=100074&uk=822373947 方法 ...

  9. 01 ~ 03 headfirst php & mysql

    Question : 难道不是所有web页面原先都放在服务器上吗? 甚至存储在.html文件中的HTML页面? Answer : 没错, 网站的所有文件都存储在服务器上, html, css, php ...

  10. tcpdump用法

    http://man.linuxde.net/tcpdump http://www.cnblogs.com/yc_sunniwell/archive/2010/07/05/1771563.html