iOS 判断版本是否升级,若是有新的版本,提醒升级
来源:互联网 发布:微信群如何做淘宝客 编辑:程序博客网 时间:2024/06/05 09:34
/** * ldz * * 检测软件是否需要升级 */-(void)checkVersion{ //获取当前应用版本号 NSDictionary *appInfo = [[NSBundle mainBundle] infoDictionary]; NSString *currentVersion = [appInfo objectForKey:@"CFBundleVersion"]; // 用__block才能在局部作用域中改变变量的值 __block NSString *newVersion = @""; NSString *updateUrlString = [NSString stringWithFormat:@"http://itunes.apple.com/lookup?id=%ld",(long)[<span style="font-size:18px;color:#FF0000;"><strong>iFeverAPPID</strong></span> integerValue]]; NSString * str = [updateUrlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager]; [manager GET:str parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) { NSLog(@"123 + %@", operation); NSDictionary *resultDic = responseObject; NSArray *resultArray = [resultDic objectForKey:@"results"]; for (id config in resultArray) { newVersion = [config valueForKey:@"version"]; } if (newVersion) { NSLog(@"通过AppStore获取的版本号是:%@", newVersion); } if ([newVersion floatValue] > [currentVersion floatValue]) { NSString *versionMessageStr = [NSString stringWithFormat:@"当前版本%@,最新版本为%@,请升级.",currentVersion,newVersion]; UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"升级提示!" message: versionMessageStr delegate:self cancelButtonTitle:@"下次再说" otherButtonTitles:@"现在升级", nil]; alert.tag = <span style="font-size:18px;color:#3333FF;">kVersionNeedUpdateAlertTag</span>; [alert show]; } } failure:^(AFHTTPRequestOperation *operation, NSError *error) { NSLog(@"234 + %@", error); }];}#pragma mark - UIAlertDelegate Method//收到推送时程序正在前台运行,则给出一个alert,用户选择查看,执行这个方法,并且跳转到指定页面-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{ if (buttonIndex == 1) { //软件需要更新提醒 if (alertView.tag == <span style="font-size:18px;color:#3333FF;">kVersionNeedUpdateAlertTag</span>) { NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"https://itunes.apple.com/cn/app/wan-zhuan-quan-cheng/id%@?mt=8",iFeverAPPID]]; [[UIApplication sharedApplication]openURL:url]; /* // 打开iTunes 方法二:此方法总是提示“无法连接到itunes”,不推荐使用 NSString *iTunesLink = @"itms-apps://phobos.apple.com/WebObjects/MZStore.woa/wa/viewSoftwareUpdate?id=%i&mt=8"; NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"itms-apps://phobos.apple.com/WebObjects/MZStore.woa/wa/viewSoftwareUpdate?id=%i&mt=8",iFeverAPPID]]; [[UIApplication sharedApplication] openURL:url]; */ } }}
//注意
<span style="color:#FF0000;"><strong>iFeverAPPID 是你公司已经上线的APP ID</strong></span>
<span style="font-size:18px;color:#3333FF;">kVersionNeedUpdateAlertTag 是为了分别你AppDelegate页面中有多个alertView</span>
0 0
- iOS 判断版本是否升级,若是有新的版本,提醒升级
- IOS 判断应用版本和升级提示
- IOS 判断应用版本和升级提示
- IOS 判断应用版本和升级提示
- IOS 判断应用版本和升级提示
- IOS 判断应用版本和升级提示
- iOS提示有新版本以及版本升级的问题
- 用JS判断浏览器是否是IE9以下,处理可能遇到的兼容性问题,或者给出浏览器版本过低的升级提醒。
- ios-版本升级检测
- IOS 版本升级思路
- IOS 版本升级提示
- iOS APP升级版本
- iOS 版本升级
- IE8版本以下浏览器升级提醒
- 新控件DevExpress版本升级
- iOS客户端的升级提醒
- iOS的版本升级报错问题
- iOS coredata的使用及版本升级
- java回调函数的初步理解
- 欢迎使用CSDN-markdown编辑器
- 程序员面试题精选100题(51)-顺时针打印矩阵[算法]
- 基于javascript上手正则表达式
- 万兆环网
- iOS 判断版本是否升级,若是有新的版本,提醒升级
- 专访雷果国:从1.5K到18K 一个程序员的5年成长之路
- 图标消息提示效果
- java源码级注解处理+字节码级注解处理
- 程序员面试题精选100题(52)-C++面试题(1)
- 麦加《解密》简评
- 正态分布,Python实现
- OWASP ZAP2.4.3使用指南(中文版)
- [BZOJ2631] tree