注:这里网络请求用的是第三方框架:SVHTTPRequest

/*

第一步: 根据应用名称搜索应用,然后根据应用绑定的ID在结果中筛选出我们要找的应用,并取出应用的AppID

*/

- (void)getAppID {

processView  = [[UIProcessViewalloc]initWithFrame:self.view.framewithText:@"检测中..."];

[processViewstartAnimating];

[self.viewaddSubview:processView];

[SVHTTPRequestPOST:@"http://itunes.apple.com/search"

parameters:[[NSDictionaryalloc] initWithObjectsAndKeys:APP_NAME,@"term",@"software",@"entity",nil]

completion:^(id response, NSHTTPURLResponse *urlResponse, NSError *error) {

if (!error&&[urlResponse statusCode]==200) {

NSData *data = (NSData *)response;

id res = [NSJSONSerializationJSONObjectWithData:data options:NSJSONReadingMutableContainerserror:nil];

NSLog(@"res.class==%@",[res class]);

NSLog(@"res == %@",res);

NSLog(@"results class == %@",[[res objectForKey:@"results"]class]);

NSArray *arr = [res objectForKey:@"results"];

for (id config in arr)

{

NSString *bundle_id = [config valueForKey:@"bundleId"];

if ([bundle_id isEqualToString:APP_BUNDLE_IDENTIFIER]) {

[processView stopAnimating];

app_id  = [config valueForKey:@"trackId"];

updateURL = [config valueForKey:@"trackViewUrl"];

NSString *app_Name = [config valueForKey:@"trackName"];

NSString *version = [config valueForKey:@"version"];

NSLog(@"app_id == %@,app_Name == %@,version == %@",app_id,app_Name,version);

[self checkUpdate:version];

}

}

} else {

[processView stopAnimating];

[CTCommonUtilsshowAlertViewOnView:self.viewwithText:@"检测失败,当前无网络连接!"];

}

}];

}

/*

第二步:通过比较从App Store获取的应用版本与当前程序中设定的版本是否一致,然后判断版本是否有更新

*/

- (void)checkUpdate:(NSString *)versionFromAppStroe {

NSDictionary *infoDict = [[NSBundlemainBundle] infoDictionary];

NSString *nowVersion = [infoDict objectForKey:@"CFBundleVersion"];

NSLog(@"nowVersion == %@",nowVersion);

[processViewstopAnimating];

//检查当前版本与appstore的版本是否一致

if (![versionFromAppStroe isEqualToString:nowVersion])

{

UIAlertView *createUserResponseAlert = [[UIAlertView alloc] initWithTitle:@"提示" message: @"有新的版本可供下载" delegate:self cancelButtonTitle:@"下次再说" otherButtonTitles: @"去下载", nil];

[createUserResponseAlert show];

} else {

[CTCommonUtilsshowAlertViewOnView:self.viewwithText:@"暂无新版本"];

}

}

#pragma mark - AertView delegate

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

{

if (buttonIndex == 1) {

   //去appstore中更新

//方法一:根据应用的id打开appstore,并跳转到应用下载页面

//NSString *appStoreLink = [NSString stringWithFormat:@"http://itunes.apple.com/cn/app/id%@",app_id];

//[[UIApplication sharedApplication] openURL:[NSURL URLWithString:appStoreLink]];

//方法二:直接通过获取到的url打开应用在appstore,并跳转到应用下载页面

[[UIApplicationsharedApplication] openURL:[NSURLURLWithString:updateURL]];

} else if (buttonIndex == 2) {

//去itunes中更新

[[UIApplicationsharedApplication] openURL:[NSURLURLWithString:@"itms://itunes.apple.com/cn/app/guang-dian-bi-zhi/id511587202?mt=8"]];

}

}

#pragma mark -

ios 实现版本更新检查的更多相关文章

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

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

  2. iOS 版本更新检查

    #pragma mark ---------------------------------- #pragma mark -- 检测版本更新 -(void)onCheckVersion { NSDic ...

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

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

  4. iOS 之 内存检查instrument

    经常听见iOS开发instrument是一个内存检查工具,但是,没想到,它是集成在xcode里面的,而且打开一看,感觉功能非常强大. 打开方式是 product -> profile 头一次运行 ...

  5. iOS检测版本更新

    有时候为了需求,我们需要检测app版本更新今天在这里整合下 //获取当前版本号 NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDi ...

  6. iOS软件版本更新思路

    iOS软件更新思路 需要更新版本数组 needUpdateVersions{1.2.61.2.8} 历史版本数组 historyUpdateVersions1.2.41.2.51.2.6 更新数据库1 ...

  7. iOS 检测版本更新

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

  8. 苹果iOS系统下检查第三方APP是否安装及跳转启动

    在iOS系统,使用Url Scheme框架在APP间互相跳转和传递数据,本文只介绍如果检测和跳转. Url Scheme框架 如果你想知道ios设备中是否安装QQ这个软件,我们可以通过一个简单方法判断 ...

  9. iOS开发 如何检查内存泄漏

    本文转载至 http://mobile.51cto.com/iphone-423391.htm 在开发的时候内存泄漏是不可避免的,但是也是我们需要尽量减少的,因为内存泄漏可能会很大程度的影响程序的稳定 ...

随机推荐

  1. gulp完全开发指南 => 快来换掉你的Grunt吧

    最近一直在构建Angular应用,通过bower管理前端包依赖,然后通过gulp和它配合.发现gulp相比于grunt真的很轻,现在我的项目中已经取代了grunt.这里把我的一些实践贴记录下来和大家分 ...

  2. UVa 3487 & 蜜汁建图

    题意: 有两家公司都想向政府申请某些资源的使用权,并且他们都提供了一些申请列表,列表中含有申请费用和资源种类,同一家公司的申请列表之间不含有重复的资源.政府只可以完整地接受和拒绝谋一份申请列表,问政府 ...

  3. Leetcode Reverse Words in a String

    Given an input string, reverse the string word by word. For example,Given s = "the sky is blue& ...

  4. 测试经验总结(“二次开发”)

    参考原文地址:http://www.51testing.com/html/86/n-3601786.html 不知不觉已经工作五年时间了,从茁壮.康拓普.利鑫云端到现在的惠卡世纪,经历过机顶盒软件(嵌 ...

  5. implicit和explicit的基本使用

    class MyAge { public int Age { get; set; } public static implicit operator MyAge(int age) { return n ...

  6. BZOJ4552: [Tjoi2016&Heoi2016]排序

    Description 在2016年,佳媛姐姐喜欢上了数字序列.因而他经常研究关于序列的一些奇奇怪怪的问题,现在他在研究一个难题 ,需要你来帮助他.这个难题是这样子的:给出一个1到n的全排列,现在对这 ...

  7. 使用C#将HTML文本转换为普通文本,去掉所有的Html标记(转)

    using System; using System.Collections.Generic; using System.Linq; using System.Text; //首先需要导入命名空间 u ...

  8. Linux文件/目录权限设置命令:chmod

    文件/目录权限设置命令:chmod 这是Linux系统管理员最常用到的命令之一,它用于改变文件或目录的访问权限.该命令有两种用法: 用包含字母和操作符表达式的文字设定法 其语法格式为:chmod [w ...

  9. linux下获取本机IP

    转载:http://blog.chinaunix.net/uid-20593763-id-1620213.html 源代码级Unix/Linux 通用网卡IP地址获取方法 在Unix和Linux系统下 ...

  10. [LintCode] Simplify Path 简化路径

    Given an absolute path for a file (Unix-style), simplify it. Have you met this question in a real in ...