注:这里网络请求用的是第三方框架: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. Win10 利用安装盘启用 .NET Framework 3.5

    以管理员身份运行命令提示符,在“管理员:命令提示符”窗口中输入以下命令:dism.exe /online /enable-feature /featurename:netfx3 /Source:D:\ ...

  2. transform应用详解

    关于css3的transform,做了一个demo,上代码 html: <!DOCTYPE html> <html> <head lang="en"& ...

  3. Code[VS] 1022 覆盖 题解

    Code[VS] 1022 覆盖 题解  Hungary Algorithm 题目传送门:Code[VS] 1022 题目描述 Description 有一个N×M的单位方格中,其中有些方格是水塘,其 ...

  4. iOS 获取UIView 动画的实时位置的方法

    [self.animationView.layer.presentationLayer frame].origin.x

  5. Java_动态加载

    Java类动态加载(一)——java源文件动态编译为class文件最近在做java动态加载这方面的工作,起初也遇到了很多困难.网上关于这方便的东西很零散,为了便于日后回过头来再看,于是我将这几天的心得 ...

  6. Spring MVC中处理静态资源的多种方法

    处理静态资源,我想这可能是框架搭建完成之后Web开发的”头等大事“了. 因为一个网站的显示肯定会依赖各种资源:脚本.图片等,那么问题来了,如何在页面中请求这些静态资源呢? 还记得Spring MVC中 ...

  7. 如何在weka中连接数据库(转)

    相关准备: Weka.mysql已安装 MYSQL Driver for JDBC 1.进入weka的安装目录 1)新建文件夹lib和文件夹weka,然后将mysql-connector-java-5 ...

  8. 快速安装zabbix agent并部署监控

    1.准备yum源: epel源:yum install -y zabbix22-agent 2.上传脚本: 上传脚本事先写好的监控脚本到/script/下面 3.修改配置文件:Server=10.10 ...

  9. Thinkphp框架感悟(一)

    一.assign() /** * 分析: * 此处是Controller类里面的assign方法,我们一般写的控制器所调用的assign方法就是调的这个. * 而这个方法就干了三件事:1.获取传过来的 ...

  10. .net 服务器端文件下载

    string path = Server.MapPath("/Source/mjpjb.rar"); System.IO.FileInfo file = new System.IO ...