iOS appStore中的应用 实现升级功能2
来源:互联网 发布:2016淘宝联盟使用教程 编辑:程序博客网 时间:2024/06/05 15:19
.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 == 1) { //打开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中的应用 实现升级功能2
- iOS appStore中的应用 实现升级功能2
- iOS appStore中的应用 实现版本升级功能
- iOS appStore 实现应用升级功能
- ios跳转appstore中应用升级和评价
- iOS app应用 跳转appStore评分 2
- IOS 应用APPStore上传
- iOS开发中,应用内直接跳转到Appstore(适合版本强制升级和跳转appstore评分)
- iOS如何实现无需跳转AppStore直接安装应用
- 上传ios应用到AppStore
- ios 发布应用到appStore
- ios 发布应用到appStore
- iOS应用内跳转appstore
- ios发布应用到appstore
- iOS 应用内跳转APPStore
- iOS应用打包提交AppStore
- iOS应用打包提交AppStore
- 实现iOS应用PUSH功能
- Java多线程学习——Condition的使用
- PAT 1030 Travel Plan (30)
- Java开发中的23种设计模式详解
- EXT学习之路【发现一个重点】会引起滚动条的异常
- C++笔试题 String类的实现 三大复制控制函数
- iOS appStore中的应用 实现升级功能2
- android开发必备知识
- Task(Activity栈) 详解
- 根文件系统的建立
- Android 如何把状态栏信号格改为5格
- Android中PopupWindow显示在指定位置
- AT&T汇编leave学习
- Reverse words in a String leetcode
- 乐观锁与悲观锁