iOS 版本更新检查
#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 版本更新检查的更多相关文章
- iOS 版本更新(强制更新)检测问题
iOS 版本更新(强制更新)检测问题 通常iOS系统中是默认设置再wifi状态,且网络状况良好下自己更新应用的. 但是如果用户设置了不自动更新,但是我们的APP出现重要的版本,一定需要用户更新的情况下 ...
- iOS 版本更新迭代
开发中我们可能会遇到这样的需求,当AppStore中有新版本迭代更新,在用户点开APP的时候弹框提醒客户去AppStore更新APP.这里面就有个关键点,判断当前APP与AppStore中的版本高低, ...
- ios 实现版本更新检查
注:这里网络请求用的是第三方框架:SVHTTPRequest /* 第一步: 根据应用名称搜索应用,然后根据应用绑定的ID在结果中筛选出我们要找的应用,并取出应用的AppID */ - (void)g ...
- iOS版本更新的App提交审核发布流程
http://www.2cto.com/kf/201502/378698.html 版本更新的App和新App的发布提交流程略有不同,新的App需要在开发者账号里准备发布证书,添加App的id,关联描 ...
- iOS版本更新的App提交审核流程
App的版本更新估计是在所难免的了!更新App和新的App发布有何不同了?今天我们一起来看看吧!在发布App的时候我们需要通过开发者帐号——(申请)——>发布证书(需要钥匙串对证书签名也叫加密( ...
- iOS7 中的新加入的下载类NSURLSession(随ios版本更新而更新)
想详细的了解网络下载的相关知识,要仔细阅读URL Loading System Programming Guide 这里有篇好文章(http://www.shinobicontrols.com/blo ...
- iOS版本更新在APP中直接访问AppStore
1.导入框架 #import <StoreKit/StoreKit.h> 2.添加代理 <SKStoreProductViewControllerDelegate> 3.设置跳 ...
- ios版本更新总结
更新思路,获取APP Store 版本号与项目本地版本号对比,如果本地低于商店版本号,就提示用户更新(说明:在上架项目时请保持本地和商店版本号一致,避免检测更新问题被拒) 1.获取商店版本号,代码如下 ...
- ios 版本更新提示-硬更新/软更新
实现: 强制更新:每次弹框 非强制更新:一天提示一次 代码如下: 步骤一: 将检测更新写到APPDelegate的applicationDidBecomeActive中 步骤二: 检测是否需要更新 步 ...
随机推荐
- js获取ifram对象
1.获取iframe对象 var doc=document.getElementById('frameId').contentWindow.document; //var doc=parent.doc ...
- UML 类图基础知识记录
UML类图关系(泛化 .继承.实现.依赖.关联.聚合.组合) 依赖(Dependency): 关联(Association): 聚合(Aggregation): 合成(Composition): 泛化 ...
- unity, 由unity5.2.1升级到5.4.2物体变亮解法
由unity5.2.1升级到5.4.2之后,使用standard shader的物体会变亮. 原因如图: 框中两项是5.4.2多出来的,如果把specular Highlights的勾选去掉,就跟以前 ...
- OpenJudge计算概论-简单算术表达式求值
/*===================================== 简单算术表达式求值 总时间限制: 1000ms 内存限制: 65536kB 描述 2位正整数的简单算术运算(只考虑整数运 ...
- Python关键字yield的解释(stackoverflow)
3.1. 提问者的问题 Python关键字yield的作用是什么?用来干什么的? 比如,我正在试图理解下面的代码: def node._get_child_candidates(self, dista ...
- hibernate 自生双向一对多 多对一管理 (树)
<span style="font-size: large;">package com.javacrazyer.test; import java.io.Seriali ...
- 记一次系统稳定性问题的分析处理过程(因CallContext使用不当而造成bug)
问题描述: 一个项目现场反馈,“差旅费类型的单据审批,在出现业务规则没满足的情况时(即业务报错,需要人机交互),审批仍然通过了”.从技术的角度上说,就是业务构件中的业务规则报错后,事务没有回滚.但是, ...
- 编译工程时报illegal character:\65279--转
windows对UTF-8文件进行了特殊处理,对UTF-8的文本文件自动在前面加了三个byte(EF BB BF),javac编译时,读到最前面这三个byte时报错 illegal character ...
- MyEclipse Hibernate 学习总结
最近在学习Hibernate,先把学习的过程记录一下,方便自己以后复习. 1.使用工具 MyEclipse 10 2. 1)新建Java程序 2)右键程序,选择MyEclipse-> Add H ...
- C#Winfrom系统打印机调用/设置默认打印机
实现如下效果: 实现方式如下: using System;using System.Drawing.Printing;using System.Runtime.InteropServices;usin ...