iOS版本检测代码(更新版本)
来源:互联网 发布:ksweb mysql 编辑:程序博客网 时间:2024/05/16 19:07
dispatch_queue_t mainQueue =dispatch_get_main_queue();
dispatch_queue_t globalQueue =dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT,0);
NSDictionary *infoDic = [[NSBundlemainBundle]infoDictionary];
NSString *currentVersion = [infoDicobjectForKey:@"CFBundleVersion"];
dispatch_async(globalQueue, ^{
NSString *URL =@"http://itunes.apple.com/lookup?id=你自己的AppID";
NSMutableURLRequest *request = [[NSMutableURLRequestalloc]init];
[requestsetURL:[NSURLURLWithString:URL]];
[requestsetHTTPMethod:@"POST"];
NSHTTPURLResponse *urlResponse =nil;
NSError *error =nil;
NSData *recervedData = [NSURLConnectionsendSynchronousRequest:requestreturningResponse:&urlResponse error:&error];
NSDictionary *dic = [NSJSONSerializationJSONObjectWithData:recervedDataoptions:NSJSONReadingMutableContainerserror:&error];
NSArray *infoArray = [dicobjectForKey:@"results"];
NSLog(@"%@", infoArray);
if ([infoArraycount]) {
NSDictionary *releaseInfo = [infoArrayobjectAtIndex:0];
NSString *lastVersion = [releaseInfoobjectForKey:@"version"];
if (![lastVersionisEqualToString:currentVersion]) {
dispatch_async(mainQueue, ^{
UIAlertView *alert = [[UIAlertViewalloc]initWithTitle:@"更新"message:@"有新的版本更新,是否前往更新?"delegate:selfcancelButtonTitle:@"关闭"otherButtonTitles:@"更新",nil];
alert.tag =10000;
[alertshow];
});
}
else
{
dispatch_async(mainQueue, ^{
UIAlertView *alert = [[UIAlertViewalloc]initWithTitle:@"更新"message:@"此版本为最新版本"delegate:selfcancelButtonTitle:@"确定"otherButtonTitles:nil,nil];
alert.tag =10001;
[alertshow];
});
}
}
});
}
这个代码是连接更新的地址
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (alertView.tag==10000) {
if (buttonIndex==1) {
NSURL *url = [NSURLURLWithString:@"https://itunes.apple.com/cn/app/ji-xun-xin-wen/id962735629?mt=8"];(这里填写的是你自己的App的连接)
[[UIApplicationsharedApplication]openURL:url];
}
}
}
- iOS版本检测代码(更新版本)
- ios检测版本更新代码
- IOS版本检测,更新版本
- iOS 检测版本更新
- iOS 检测版本更新
- IOS检测版本更新
- iOS检测版本更新
- iOS 检测版本更新
- iOS 检测版本更新
- IOS 版本更新检测
- iOS 检测版本更新
- iOS 检测版本更新
- iOS --检测更新版本
- ios检测版本更新
- iOS 检测版本更新
- iOS 检测版本更新
- iOS 检测版本更新
- iOS 检测版本更新
- 怎样使用Google App Engine
- 例题10-7 交表 UVa10820
- 程序员绩效考核表
- Java 校验日期(格式:yyyyMMdd)
- 【Puppet2D】教程1
- iOS版本检测代码(更新版本)
- class from quick
- D7100 如何拍出黑白照片中只显示指定一种或多种颜色
- unity3d 基于物理渲染的问题解决
- 九度OJ题目1041:Simple Sorting
- MongoDB权威指南—读书笔记(Part one)
- 【Puppet2D】教程2
- SSL/TLS协议运行机制的概述
- MongoDB权威指南—读书笔记(Part Two)