#pragma mark ----------------------------------

#pragma mark -- 检测版本更新

-(void)onCheckVersion

{

NSDictionary *infoDic = [[NSBundlemainBundle] infoDictionary];

NSString *currentVersion = [infoDic objectForKey:@"CFBundleShortVersionString"];//CFBundleVersion

NSString *URL = @"http://itunes.apple.com/lookup?id=你的appId";

NSMutableURLRequest *request = [[NSMutableURLRequestalloc] init];

[request setURL:[NSURL URLWithString:URL]];

[request setHTTPMethod:@"POST"];

[NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue currentQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError) {

if (data == nil) {

return ;

}

NSDictionary *dic = [NSJSONSerializationJSONObjectWithData:data options:NSJSONReadingMutableContainerserror:nil];

NSArray *infoArray = [dic objectForKey:@"results"];

if ([infoArray count]) {

NSDictionary *releaseInfo = [infoArray objectAtIndex:0];

NSString *lastVersion = [releaseInfo objectForKey:@"version"];

//测试数据

//        currentVersion = @"1.1";

//        lastVersion = @"1.1.1";

//版本号处理并比较大小

NSMutableArray *lastVersionArr = [NSMutableArray arrayWithArray:[lastVersion componentsSeparatedByString:@"."]];

NSMutableArray *currentVersionArr = [NSMutableArray arrayWithArray:[currentVersion componentsSeparatedByString:@"."]];

BOOL haveNewVersion = NO;

//比较数组长度 不相等则 补零至相等

if (lastVersionArr.count > currentVersionArr.count) {

for (int i = 0 ; i < lastVersionArr.count - currentVersionArr.count; ++i) {

[currentVersionArr addObject:@"0"];

}

}else if (lastVersionArr.count < currentVersionArr.count){

for (int i = 0 ; i < currentVersionArr.count - lastVersionArr.count; ++i) {

[lastVersionArr addObject:@"0"];

}

}

//比较大小

for (int i = 0 ; i < currentVersionArr.count; ++i) {

if ([lastVersionArr[i] integerValue] > [currentVersionArr[i] integerValue]) {

haveNewVersion = YES;

[SettingsManager shareInstance].hasNewVersion = YES;

break;

}else if ([lastVersionArr[i] integerValue] < [currentVersionArr[i] integerValue])

{

haveNewVersion = NO;

[SettingsManager shareInstance].hasNewVersion = NO;

break;

}

}

if (haveNewVersion) {

UIAlertView *alert = [[UIAlertViewalloc] initWithTitle:NSLocalizedString(@"更新", nil) message:[releaseInfo  objectForKey:@"releaseNotes"] delegate:selfcancelButtonTitle:NSLocalizedString(@"取消", nil) otherButtonTitles:NSLocalizedString(@"前往更新", nil), nil];

alert.tag = 10000;

[alert show];

}

}

}];

}

#pragma mark - AertView delegate

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

{

if (alertView.tag == 10000) {

if (buttonIndex == 1) {

[[UIApplicationsharedApplication] openURL:[NSURLURLWithString:@"你的App下载地址"]];

}

}

}

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

  1. iOS 版本更新(强制更新)检测问题

    iOS 版本更新(强制更新)检测问题 通常iOS系统中是默认设置再wifi状态,且网络状况良好下自己更新应用的. 但是如果用户设置了不自动更新,但是我们的APP出现重要的版本,一定需要用户更新的情况下 ...

  2. iOS 版本更新迭代

    开发中我们可能会遇到这样的需求,当AppStore中有新版本迭代更新,在用户点开APP的时候弹框提醒客户去AppStore更新APP.这里面就有个关键点,判断当前APP与AppStore中的版本高低, ...

  3. ios 实现版本更新检查

    注:这里网络请求用的是第三方框架:SVHTTPRequest /* 第一步: 根据应用名称搜索应用,然后根据应用绑定的ID在结果中筛选出我们要找的应用,并取出应用的AppID */ - (void)g ...

  4. iOS版本更新的App提交审核发布流程

    http://www.2cto.com/kf/201502/378698.html 版本更新的App和新App的发布提交流程略有不同,新的App需要在开发者账号里准备发布证书,添加App的id,关联描 ...

  5. iOS版本更新的App提交审核流程

    App的版本更新估计是在所难免的了!更新App和新的App发布有何不同了?今天我们一起来看看吧!在发布App的时候我们需要通过开发者帐号——(申请)——>发布证书(需要钥匙串对证书签名也叫加密( ...

  6. iOS7 中的新加入的下载类NSURLSession(随ios版本更新而更新)

    想详细的了解网络下载的相关知识,要仔细阅读URL Loading System Programming Guide 这里有篇好文章(http://www.shinobicontrols.com/blo ...

  7. iOS版本更新在APP中直接访问AppStore

    1.导入框架 #import <StoreKit/StoreKit.h> 2.添加代理 <SKStoreProductViewControllerDelegate> 3.设置跳 ...

  8. ios版本更新总结

    更新思路,获取APP Store 版本号与项目本地版本号对比,如果本地低于商店版本号,就提示用户更新(说明:在上架项目时请保持本地和商店版本号一致,避免检测更新问题被拒) 1.获取商店版本号,代码如下 ...

  9. ios 版本更新提示-硬更新/软更新

    实现: 强制更新:每次弹框 非强制更新:一天提示一次 代码如下: 步骤一: 将检测更新写到APPDelegate的applicationDidBecomeActive中 步骤二: 检测是否需要更新 步 ...

随机推荐

  1. network Driver , TDI(Transport Driver Interface) Drivers

    https://msdn.microsoft.com/en-us/library/windows/hardware/ff565094(v=vs.85).aspx https://msdn.micros ...

  2. 关于margin和padding的总结

    总结一下: 要想实现如(图一)效果,(即一个div中的子元素与父元素有间距): 如果类名为.middle的父元素没有写border,则类名为firstChild的子元素设置margin-top,会导致 ...

  3. Unity3D研究院编辑器之脚本设置ToolBar

    Unity版本5.3.2 如下图所示,ToolBar就是Unity顶部的那一横条.这里的所有按钮一般情况下都得我们手动的用鼠标去点击.这篇文章我们说说如果自动操作它们 1.自动点击左边四个按钮 (拖动 ...

  4. 联想笔记本如何关闭功能键,快捷键,如Fn+F1与F1切换

    在BIOS设置界面,进入 "Configuration" 菜单,查看是否有"Hotkey mode"选项,如果有的话,您由Enable更改为Disable,然后 ...

  5. python_Day1_基础知识开篇

    一.python安装 1)windows上同时安装python2.0和python3.0配置 (1)在python官网下载windows版本python2.0和python3.0安装包 官网地址:ht ...

  6. linux包之sysstat之sar命令

    要启动SAR,必须通过cron工具以周期性的间隔启动.安装sysstat包后,默认创建一个/etc/cron.d/sysstat文件,其默认内容为:# run system activity acco ...

  7. CSS3 必须要知道的10 个顶级命令

    来源:http://www.cnblogs.com/damonlan/archive/2012/04/23/2465569.html 作者:浪迹天涯 1.边框圆角(Border Radiuas) 这个 ...

  8. xunsearch安装配置

    1.wget http://www.xunsearch.com/download/xunsearch-full-latest.tar.bz2 2.tar -xjf xunsearch-full-lat ...

  9. RSA非对称加密 php的openssl实现

    <?php /** * 使用openssl实现非对称加密 * @since 2010-07-08 */ class Rsa { /** * private key */ private $_pr ...

  10. Dubbo架构设计详解-转

    Dubbo架构设计详解  2013-09-03 21:26:59    Yanjun Dubbo是Alibaba开源的分布式服务框架,它最大的特点是按照分层的方式来架构,使用这种方式可以使各个层之间解 ...