iOS 版本更新
来源:互联网 发布:参与php开源项目 编辑:程序博客网 时间:2024/06/16 18:06
/**
* 检测app更新
*/
-(void)hsUpdateApp
{
//2先获取当前工程项目版本号
NSDictionary *infoDic=[[NSBundlemainBundle] infoDictionary];
NSString *currentVersion=infoDic[@"CFBundleShortVersionString"];
//3从网络获取appStore版本号
NSError *error;
NSData *response = [NSURLConnectionsendSynchronousRequest:[NSURLRequestrequestWithURL:[NSURLURLWithString:[NSStringstringWithFormat:@"http://itunes.apple.com/cn/lookup?id=%@",STOREAPPID]]]returningResponse:nilerror:nil];
if (response == nil) {
XMGLog(@"你没有连接网络哦");
return;
}
NSDictionary *appInfoDic = [NSJSONSerializationJSONObjectWithData:response options:NSJSONReadingMutableLeaveserror:&error];
if (error) {
XMGLog(@"hsUpdateAppError:%@",error);
return;
}
NSArray *array = appInfoDic[@"results"];
NSDictionary *dic = array[0];
NSString *appStoreVersion = dic[@"version"];
//打印版本号
XMGLog(@"当前版本号:%@\n商店版本号:%@",currentVersion,appStoreVersion);
//4当前版本号小于商店版本号,就更新
if([currentVersion floatValue] < [appStoreVersionfloatValue])
{
UIAlertView *alert = [[UIAlertViewalloc] initWithTitle:@"版本有更新"message:[NSStringstringWithFormat:@"检测到新版本(%@),是否更新?",appStoreVersion]delegate:selfcancelButtonTitle:@"取消"otherButtonTitles:@"更新",nil];
[alertshow];
}else{
XMGLog(@"版本号好像比商店大噢!检测到不需要更新");
}
}
- (void)alertView:(UIAlertView*)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
//5实现跳转到应用商店进行更新
if(buttonIndex==1)
{
//6此处加入应用在app store的地址,方便用户去更新,一种实现方式如下:
NSURL *url = [NSURLURLWithString:[NSStringstringWithFormat:@"https://itunes.apple.com/us/app/id%@?ls=1&mt=8",STOREAPPID]];
[[UIApplicationsharedApplication] openURL:url];
}
}
- IOS版本检测,更新版本
- iOS 检测版本更新
- ios检查版本更新
- ios版本更新
- iOS 检测版本更新
- IOS检测版本更新
- IOS版本更新
- ios检查版本更新
- iOS检测版本更新
- iOS 检测版本更新
- ios版本更新
- iOS 版本更新
- iOS 检测版本更新
- IOS 版本更新检测
- iOS 检测版本更新
- iOS 检测版本更新
- iOS --检测更新版本
- IOS 版本检查更新
- Java如何对ArrayList里的元素排序
- iOS打开摄像头录像
- PAT L3-001. 凑零钱(背包&路径记录)
- layoutSubviews调用情况
- c++作业6
- iOS 版本更新
- 关于指针的知识点
- 2dx-lua游戏震屏效果&简单的lua-binding
- dex2jar 使用
- 开发中碰到的问题:android java.lang.UnsatisfiedLinkError:
- 基于Oracle的私有云架构探析(连载一)
- Arduino入门教程—RFID模块的使用(MF RC522)
- C++ string类型详解
- java中dao层和service层的区别,为什么要用service?