iOS 应用版本检测更新
来源:互联网 发布:php导入excel 编辑:程序博客网 时间:2024/05/22 09:38
-(void)checkVersion:(id)sender{
dict_version=[[senderobjectFromJSONData]copy];
//获取用户安装当前客户端的版本号
NSDictionary*infoDictionary = [[NSBundlemainBundle]infoDictionary];
//版本号存入数组
NSString*now_version = [infoDictionary objectForKey:@"CFBundleVersion"];
//版本号存入数组
NSArray *local_version_arr=[now_version componentsSeparatedByString:@"."];
////NSLog(@"local_version_arr is %@",local_version_arr);
//从服务器获取的版本号
NSString*new_version = [dict_versionobjectForKey:@"version"];
//从服务器获取的更新内容
NSString*updateContern = [dict_versionobjectForKey:@"update_content"];
//判断获取的内容是不是正确
if (![new_version isEqual:[NSNullnull]] && ![new_versionisEqual:@""]) {
//将版本号以“.”为间隔存入数组中
NSArray*new_version_arr=[new_version componentsSeparatedByString:@"."];
//比较服务器版本号和当前应用版本号
for (int i=0; i<[new_version_arrcount];i++ ) {
if([[new_version_arr objectAtIndex:i] intValue]>[[local_version_arr objectAtIndex:i] intValue]) {
UIAlertView*updateAlert=[[UIAlertViewalloc]initWithTitle:@"版本更新提示"message:updateConterndelegate:selfcancelButtonTitle:@"稍后提示"otherButtonTitles:@"现在更新",nil];
[updateAlert show];
[updateAlert release];
break;
}elseif ([[new_version_arr objectAtIndex:i]intValue]==[[local_version_arrobjectAtIndex:i]intValue]) {
continue;
}else{
return;
}
dict_version=[[senderobjectFromJSONData]copy];
//获取用户安装当前客户端的版本号
NSDictionary*infoDictionary = [[NSBundlemainBundle]infoDictionary];
//版本号存入数组
NSString*now_version = [infoDictionary objectForKey:@"CFBundleVersion"];
//版本号存入数组
NSArray *local_version_arr=[now_version componentsSeparatedByString:@"."];
////NSLog(@"local_version_arr is %@",local_version_arr);
//从服务器获取的版本号
NSString*new_version = [dict_versionobjectForKey:@"version"];
//从服务器获取的更新内容
NSString*updateContern = [dict_versionobjectForKey:@"update_content"];
//判断获取的内容是不是正确
if (![new_version isEqual:[NSNullnull]] && ![new_versionisEqual:@""]) {
//将版本号以“.”为间隔存入数组中
NSArray*new_version_arr=[new_version componentsSeparatedByString:@"."];
//比较服务器版本号和当前应用版本号
for (int i=0; i<[new_version_arrcount];i++ ) {
if([[new_version_arr objectAtIndex:i] intValue]>[[local_version_arr objectAtIndex:i] intValue]) {
UIAlertView*updateAlert=[[UIAlertViewalloc]initWithTitle:@"版本更新提示"message:updateConterndelegate:selfcancelButtonTitle:@"稍后提示"otherButtonTitles:@"现在更新",nil];
[updateAlert show];
[updateAlert release];
break;
}elseif ([[new_version_arr objectAtIndex:i]intValue]==[[local_version_arrobjectAtIndex:i]intValue]) {
continue;
}else{
return;
}
}
}
}
#pragma mark - uialert delegate
- (void)alertView:(UIAlertView*)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
if (buttonIndex ==1) {
NSLog(@"downloadUrl is %@",[dict_versionobjectForKey:@"downloadUrl"]);
}
#pragma mark - uialert delegate
- (void)alertView:(UIAlertView*)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
if (buttonIndex ==1) {
NSLog(@"downloadUrl is %@",[dict_versionobjectForKey:@"downloadUrl"]);
[[UIApplicationsharedApplication]openURL:[NSURLURLWithString:[dict_versionobjectForKey:@"downloadUrl"]]];
//[[UIApplicationsharedApplication] openURL:[NSURL URLWithString:@"itms-services://?action=download-manifest&url=https://xxx.plist"]];
}
}
0 0
- iOS 应用版本检测更新
- iOS 检测版本更新
- iOS 检测版本更新
- IOS检测版本更新
- iOS检测版本更新
- iOS 检测版本更新
- iOS 检测版本更新
- IOS 版本更新检测
- iOS 检测版本更新
- iOS 检测版本更新
- iOS --检测更新版本
- ios检测版本更新
- iOS 检测版本更新
- iOS 检测版本更新
- iOS 检测版本更新
- iOS 检测版本更新
- iOS 检测版本更新
- iOS 检测版本更新
- Facebook产品设计总监:设计B端产品的4项基本原则
- jquery根据长度省略文字
- Ubuntu 14.04.1 LTS下JVM时区与系统时区不同解决
- 用SQL游标遍历循环数据的方法
- arrayadapter适配器
- iOS 应用版本检测更新
- 循环冗余校验检错方案CRC的原理介绍
- Android Volley完全解析(四),带你从源码的角度理解Volley
- 使用jdbc获取关系型数据库文件大字段,并还原成文件
- style 实例
- 第一节、本地环境的搭配及安装配置
- 2015 沈阳 区域赛 F FROGS 莫比乌斯反演
- 大数据研究常用软件工具与应用场景
- HTML5文件上传FileReader API