.h文件中

<UIAlertViewDelegate>

.m文件中

#import "SBJson.h"        //解析sbjson 数据

- (void)viewDidLoad
{
[super viewDidLoad]; ⋯⋯ [self checkVersion]; //检测升级 }
#pragma mark - 实现升级功能

//检测软件是否需要升级
-(void)checkVersion
{
NSString *newVersion;
NSURL *url = [NSURL URLWithString:@"http://itunes.apple.com/cn/lookup?id=692579125"]; //通过url获取数据
NSString *jsonResponseString = [NSString stringWithContentsOfURL:url encoding:NSUTF8StringEncoding error:nil];
NSLog(@"通过appStore获取的数据是:%@",jsonResponseString); //解析json数据为数据字典
NSDictionary *loginAuthenticationResponse = [self dictionaryFromJsonFormatOriginalData:jsonResponseString]; //从数据字典中检出版本号数据
NSArray *configData = [loginAuthenticationResponse valueForKey:@"results"];
for(id config in configData)
{
newVersion = [config valueForKey:@"version"];
} NSLog(@"通过appStore获取的版本号是:%@",newVersion); //获取本地软件的版本号
NSString *localVersion = [[[NSBundle mainBundle]infoDictionary] objectForKey:@"CFBundleVersion"]; NSString *msg = [NSString stringWithFormat:@"你当前的版本是V%@,发现新版本V%@,是否下载新版本?",localVersion,newVersion]; //对比发现的新版本和本地的版本
if ([newVersion floatValue] > [localVersion floatValue])
{
UIAlertView *createUserResponseAlert = [[UIAlertView alloc] initWithTitle:@"升级提示!" message:msg delegate:self cancelButtonTitle:@"下次再说" otherButtonTitles: @"现在升级", nil];
[createUserResponseAlert show];
[createUserResponseAlert release];
}
} //响应升级提示按钮
- (void)alertView:(UIAlertView *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
//如果选择“现在升级”
if (buttonIndex == )
{
//打开iTunes 方法一
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"https://itunes.apple.com/cn/app/wan-zhuan-quan-cheng/id692579125?mt=8"]]; /*
// 打开iTunes 方法二:此方法总是提示“无法连接到itunes”,不推荐使用
NSString *iTunesLink = @"itms-apps://phobos.apple.com/WebObjects/MZStore.woa/wa/viewSoftwareUpdate?id=692579125&mt=8";
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:iTunesLink]];
*/
}
} #pragma mark - 辅助方法:将json 格式的原始数据转解析成数据字典
//将json 格式的原始数据转解析成数据字典
-(NSMutableDictionary *)dictionaryFromJsonFormatOriginalData:(NSString *)str
{
SBJsonParser *sbJsonParser = [[SBJsonParser alloc]init];
NSError *error = nil; //添加autorelease 解决 内存泄漏问题
NSMutableDictionary *tempDictionary = [[[NSMutableDictionary alloc]initWithDictionary:[sbJsonParser objectWithString:str error:&error]]autorelease];
return tempDictionary;
}

参考:

//基于企业级证书的IOS应用打包升级功能介绍

http://blog.csdn.net/sbvfhp/article/details/10336715

//另一种代码实现思路

http://hi.baidu.com/wwssttt/item/7446105e3c98fa3933e0a9d5

//向appStore获取软件版本的代码,有步骤

http://blog.csdn.net/wave_1102/article/details/7463697

//向 appstore 查询已发布 APP 的信息--纯思路

http://hi.baidu.com/yanh105/item/7378a98ffca6a8804414cfa0

//官方帮助文档

http://www.apple.com/itunes/affiliates/resources/documentation/itunes-store-web-service-search-api.html

//如何改进iOS客户端的升级提醒功能

http://www.cocoachina.com/applenews/devnews/2013/0108/5495.html

//ios项目如何实现版本更新?

http://blog.csdn.net/mad1989/article/details/8130013

//解决向appStore 发送请求获取版本,没有返回信息的问题

http://www.cocoachina.com/ask/questions/show/56158

iOS appStore中的应用 实现升级功能的更多相关文章

  1. iOS 8 中如何集成 Touch ID 功能

    2013年9月,苹果为当时发布的最新iPhone产品配备了一系列硬件升级方案.在iPhone 5s当中,最具创新特性的机制无疑要数围绕Home按钮设计的超薄金属圈,也就是被称为Touch ID的指纹传 ...

  2. 分分钟解决iOS开发中App启动广告的功能

    前不久有朋友需要一个启动广告的功能,我说网上有挺多的,他说,看的不是很理想.想让我写一个,于是乎,抽空写了一个,代码通俗易懂,简单的封装了一下,各种事件用block回调的,有俩种样式的广告,一种是全屏 ...

  3. iOS开发中打开本地应用、打开appStore应用、给app评分功能实现

    app开发中,通常会有邀请用户给app打分的功能.而在iOS中,正式应用都是通过appStore 下载的,因此给app 打分也只能在 appStore中.因此,需要从应用跳转到appStore.方法是 ...

  4. iOS开发中打电话发短信等功能的实现

    在APP开发中,可能会涉及到打电话.发短信.发邮件等功能.比如说,通常一个产品的"关于"页面,会有开发者的联系方式,理想情况下,当用户点击该电话号码时,能够自动的帮用户拨出去,就涉 ...

  5. (转)基于企业级证书的IOS应用打包升级功能介绍

    IOS应用程序升级流程介绍:IOS手机端应用程序需要升级时,打开服务器端html文件(本文为ucab.html文件)->点击在线安装->打开plist文件(本文中为ucab.plist文件 ...

  6. iOS开发中文件的上传和下载功能的基本实现-备用

    感谢大神分享 这篇文章主要介绍了iOS开发中文件的上传和下载功能的基本实现,并且下载方面讲到了大文件的多线程断点下载,需要的朋友可以参考下 文件的上传 说明:文件上传使用的时POST请求,通常把要上传 ...

  7. iOS开发中,应用内直接跳转到Appstore

    iOS开发中,应用内直接跳转到Appstore 1.进入appstore中指定的应用NSString *str = [NSString stringWithFormat:                ...

  8. iOS开发中WiFi相关功能总结

    http://www.cocoachina.com/ios/20160715/17022.html 投稿文章,作者:Haley_Wong(简书) 查漏补缺集是自己曾经做过相关的功能,但是重做相关功能或 ...

  9. 在 iOS 应用中直接跳转到 AppStore 的方法--备用

    找到应用程序的描述链接,比如:http://itunes.apple.com/gb/app/yi-dong-cai-bian/id391945719?mt=8 然后将 http:// 替换为 itms ...

随机推荐

  1. 如何使用 JMeter 调用你的 Restful Web Service?进行简单的压力测试和自动化测试

    表述性状态传输(REST)作为对基于 SOAP 和 Web 服务描述语言(WSDL)的 Web 服务的简单替代,在 Web 开发上得到了广泛的接受.能够充分证明这点的是主流 Web 2.0 服务提供商 ...

  2. linux下nc提交web报文问题

    1.用wireshark截取访问百度首页拿到的请求数据包: GET /index.php?tn=newbdie_bd_dg&bar= HTTP/1.1 Host: www.baidu.com ...

  3. Entity Framework Code First 在Object Join Linq查询时出现全表查询的语句。

    最近一个项目,使用微软的Entity Framework的ORM框架的项目,部署到现场后,出现了系统缓慢,多个客户端的内存溢出崩溃的问题. 打开了SQL Server Profiler(SQL Ser ...

  4. HTML5元素1

    文档和元数据元素 元素 说明 类型 HTML5与其他的变化 base 设置相对URL的基础 元数据 无变化 body 表示HTML文档的内容 无 有变化 DOCTYPE 表示HTML文档的开始 无 有 ...

  5. day6 hashlib模块

        hashlib模块 用于加密相关的文件操作,3.X离代替了md5模块和sha模块,主要提供SHA1,SHA224,SHA256,SHA384,SHA512,MD5算法 __always_sup ...

  6. USACO 6.5 Closed Fences

    Closed Fences A closed fence in the plane is a set of non-crossing, connected line segments with N c ...

  7. USACO 4.3 Buy Low, Buy Lower

    Buy Low, Buy Lower The advice to "buy low" is half the formula to success in the stock mar ...

  8. 采用Post请求的方式提交参数并导出excel

    一般情况下,我们都是采用get请求的方式导出excel.例如采用如下方式: var exportUrl = '/xxx;'; window.open(exportUrl); 导出excel所需的逻辑参 ...

  9. linux查找文件或目录命令

    inux查找文件或目录命令,前提:知道文件或者目录的具体名字,例如:sphinx.conf find 查找  find / -name dirname  查找目录 find -name filenam ...

  10. [SQL]196. Delete Duplicate Emails

    Write a SQL query to delete all duplicate email entries in a table named Person, keeping only unique ...