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中 步骤二: 检测是否需要更新 步 ...
随机推荐
- tomcat maven book
https://www.amazon.com/gp/aw/d/0596517335/ref=pd_aw_sim_14_3?ie=UTF8&psc=1&refRID=H34H0BX247 ...
- Verilog
1.位拼接运算符{}
- Uinty3d 镜面反射代码
镜面反射代码 文件名MirrorReflection.cs 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 2 ...
- __flash__removeCallback 未定义错误
使用swfupload作为上传组件,artdialog作为弹出窗口,在关闭弹出窗口时,出现"__flash__removeCallback"未定义错误.而且是关了又出现.网上有些解 ...
- playframework1.x的eclipse插件开源-playtools
playtools介绍 playframework(1.2.x)是一款令人兴奋的java restful风格的web框架,使用它已经有两年多. 其中结合eclipse开发项目往往要不断进行cmd窗口切 ...
- Android 如何全局获取Context
有时,在处理业务逻辑的时候,需要Context对象,但在某些情况下,并非容易获取,这时就需要一些巧妙的手段来管理Context. 在Android中,提供了一个类Application,当应用程序启动 ...
- 任我行 CRM 9.4
下载地址: http://ftp.wecrm.com/azb/graspcrm_ect_v9.4.rar 200用户补丁下载地址: http://bbs.sunwy.org/thread-197862 ...
- Dynamics CRM4.0 和 Dynamics CRM2011 Plugin 实现一样的功能的方法的比较
1.给类型赋值不同 CRM4 plugin给lookup赋值为空 : Lookup lookupnull = new Lookup(); lookupnull.IsNull = true; looku ...
- MySQL 利用SQL线程对Binlog操作(转)
背景: 对于MySQL的binlog的查看都是用其自带的工具mysqlbinlog进行操作的,其实还有另一个方法来操作binlog,就是Replication中的SQL线程去操作binlog,其实bi ...
- DBA常用SQL之会话与等待事件
SELECT * FROM V$SESSION WHERE USERNAME IS NOT NULL AND STATUS = 'ACTIVE' ORDER BY LOGON_TIME, SID; 1 ...