版本检测更新 调用AppStore 显示自己的app
来源:互联网 发布:阿里云账户注销 编辑:程序博客网 时间:2024/06/04 19:54
#pragma mark - 检查更新 - (void)checkUpdateWithAPPID:(NSString *)APPID { //获取当前应用版本号 NSDictionary *appInfo = [[NSBundle mainBundle] infoDictionary]; NSString *currentVersion = [appInfo objectForKey:@"CFBundleVersion"]; NSString *updateUrlString = [NSString stringWithFormat:@"http://itunes.apple.com/lookup?id=%@",APPID]; NSURL *updateUrl = [NSURL URLWithString:updateUrlString]; versionRequest = [ASIFormDataRequest requestWithURL:updateUrl]; [versionRequest setRequestMethod:@"GET"]; [versionRequest setTimeOutSeconds:60]; [versionRequest addRequestHeader:@"Content-Type" value:@"application/json"]; //loading view CustomAlertView *checkingAlertView = [[CustomAlertView alloc] initWithFrame:NAVIGATION_FRAME style:CustomAlertViewStyleDefault noticeText:@"正在检查更新..."]; checkingAlertView.userInteractionEnabled = YES; [self.navigationController.view addSubview:checkingAlertView]; [checkingAlertView release]; [versionRequest setCompletionBlock:^{ [checkingAlertView removeFromSuperview]; NSError *error = nil; NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:[versionRequest responseData] options:NSJSONReadingMutableContainers error:&error]; if (!error) { if (dict != nil) { // DLog(@"dict %@",dict); int resultCount = [[dict objectForKey:@"resultCount"] integerValue]; if (resultCount == 1) { NSArray *resultArray = [dict objectForKey:@"results"]; // DLog(@"version %@",[resultArray objectAtIndex:0]); NSDictionary *resultDict = [resultArray objectAtIndex:0]; // DLog(@"version is %@",[resultDict objectForKey:@"version"]); NSString *newVersion = [resultDict objectForKey:@"version"]; if ([newVersion doubleValue] > [currentVersion doubleValue]) { NSString *msg = [NSString stringWithFormat:@"最新版本为%@,是否更新?",newVersion]; newVersionURlString = [[resultDict objectForKey:@"trackViewUrl"] copy]; DLog(@"newVersionUrl is %@",newVersionURlString); // if ([newVersionURlString hasPrefix:@"https"]) { // [newVersionURlString replaceCharactersInRange:NSMakeRange(0, 5) withString:@"itms-apps"]; // } UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"提示" message:msg delegate:self cancelButtonTitle:@"暂不" otherButtonTitles:@"立即更新", nil nil]; alertView.tag = 1000; [alertView show]; [alertView release]; }else { UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"提示" message:@"您使用的是最新版本!" delegate:self cancelButtonTitle:nil otherButtonTitles:@"确定", nil nil]; alertView.tag = 1001; [alertView show]; [alertView release]; } } } }else { DLog("error is %@",[error debugDescription]); } }]; [versionRequest setFailedBlock:^{ [checkingAlertView removeFromSuperview]; CustomAlertView *alertView = [[CustomAlertView alloc] initWithFrame:NAVIGATION_FRAME style:CustomAlertViewStyleWarning noticeText:@"操作失败,请稍候再试!"]; [self.navigationController.view addSubview:alertView]; [alertView release]; [alertView selfRemoveFromSuperviewAfterSeconds:1.0]; }]; [versionRequest <span class="string">startAsynchronous];//开始异步请求</span> } - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex { DLog(@"newVersionUrl is %@",newVersionURlString); if (buttonIndex) { if (alertView.tag == 1000) { if(newVersionURlString) { [[UIApplication sharedApplication] openURL:[NSURL URLWithString:newVersionURlString]]; } } } }
调用AppStore显示自己的app:
- (void)openAppaleShop{ NSString *appleID = @"949346638"; if ([UIDevice isIOS7]) { NSString *str = [NSString stringWithFormat:@"itms-apps://itunes.apple.com/app/id%@",appleID]; [[UIApplication sharedApplication] openURL:[NSURL URLWithString:str]]; } else { NSString *str = [NSString stringWithFormat:@"itms-apps://ax.itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id=%@", appleID]; [[UIApplication sharedApplication] openURL:[NSURL URLWithString:str]]; }}
0 0
- 版本检测更新 调用AppStore 显示自己的app
- 检测app版本更新根据AppStore
- 检测app版本更新根据AppStore
- iOS开发笔记--调用打开AppStore显示自己的App
- iOS开发笔记--调用打开AppStore显示自己的App
- iOS开发检测AppStore版本更新
- App检测版本更新 iOS
- iOS App检测版本更新
- iOS App 的版本更新检测的方法
- iOS App 的版本更新检测的方法
- AppStore审核新规则:带有版本更新的App将被拒绝
- 检测AppStore软件更新
- iOS App的版本检测更新功能(最新版)
- [ios]获取app版本更新检测的不同语言信息
- 初次发布自己的App到AppStore
- app上传至AppStore记录 及更新版本上传
- [iOS]AppStore中APP版本更新流程梳理
- iOS版本的APP已上线,但是AppStore里面按钮显示的是打开
- CocoaPods 的又一个小坑 required by `Podfile`
- Tools ------ Download ------Installing the SDK
- 移动web如何显示出滚动条
- ArcGIS相关资源整理
- 重写和重载的区别
- 版本检测更新 调用AppStore 显示自己的app
- 数据库的增长方式
- Lucene--DirectoryReader
- 查找rust平台相关代码的文档
- JAVA面试知识分类
- ubuntu下查看tomcat运行状态
- P11 (*) Modified run-length encoding.
- 使用 CSS3 新属性 user-select 控制网页内容的选择范围
- 一键打电话