判断当前app版本和appstore的版本
2016-10-09 15:03
162 查看
http://www.360doc.com/content/15/0728/18/19119980_487992185.shtml
/**
* 判断app安装版本和商店版本的比较
*/
-(void)judgeAPPVersion
{
// https://itunes.apple.com/lookup?id=604685049
NSString *urlStr = @"https://itunes.apple.com/lookup?id=604685049";
NSURL *url = [NSURL URLWithString:urlStr];
NSURLRequest *req = [NSURLRequest requestWithURL:url];
[NSURLConnection connectionWithRequest:req delegate:self];
}
-(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
NSError *error;
id jsonObject = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingAllowFragments error:&error];
NSDictionary *appInfo = (NSDictionary *)jsonObject;
NSArray *infoContent = [appInfo objectForKey:@"results"];
NSString *version = [[infoContent objectAtIndex:0] objectForKey:@"version"];
NSLog(@"商店的版本是 %@",version);
NSDictionary *infoDic = [[NSBundle mainBundle] infoDictionary];
NSString *currentVersion = [infoDic objectForKey:@"CFBundleShortVersionString"];
NSLog(@"当前的版本是 %@",currentVersion);
if (![version isEqualToString:currentVersion]) {
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:nil message:@"商店有最新版本了" delegate:nil cancelButtonTitle:@"YES" otherButtonTitles:nil,nil];
[alert show];
}
}
当然你还是可以在页面有个跳转到商店更新APP的接口的按钮滴!
[[UIApplication sharedApplication]
openURL:[NSURL URLWithString:trackViewUrl]];
/**
* 判断app安装版本和商店版本的比较
*/
-(void)judgeAPPVersion
{
// https://itunes.apple.com/lookup?id=604685049
NSString *urlStr = @"https://itunes.apple.com/lookup?id=604685049";
NSURL *url = [NSURL URLWithString:urlStr];
NSURLRequest *req = [NSURLRequest requestWithURL:url];
[NSURLConnection connectionWithRequest:req delegate:self];
}
-(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
NSError *error;
id jsonObject = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingAllowFragments error:&error];
NSDictionary *appInfo = (NSDictionary *)jsonObject;
NSArray *infoContent = [appInfo objectForKey:@"results"];
NSString *version = [[infoContent objectAtIndex:0] objectForKey:@"version"];
NSLog(@"商店的版本是 %@",version);
NSDictionary *infoDic = [[NSBundle mainBundle] infoDictionary];
NSString *currentVersion = [infoDic objectForKey:@"CFBundleShortVersionString"];
NSLog(@"当前的版本是 %@",currentVersion);
if (![version isEqualToString:currentVersion]) {
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:nil message:@"商店有最新版本了" delegate:nil cancelButtonTitle:@"YES" otherButtonTitles:nil,nil];
[alert show];
}
}
当然你还是可以在页面有个跳转到商店更新APP的接口的按钮滴!
[[UIApplication sharedApplication]
openURL:[NSURL URLWithString:trackViewUrl]];
相关文章推荐
- 获取当前手机App版本以及AppStore中的最新版本,判断是否需要更新
- 判断当前app的版本
- iOS开发 判断当前APP版本和升级
- IOS--OC获取app应用版本的信息和当前设备的各种信息,跳转到appstore(二)
- iOS 判断当前app版本,升级
- iOS 获取当前APP在APPStore上的版本信息等
- iOS开发 判断当前APP版本和升级
- iOS开发 判断当前APP版本和升级
- 关于App版本判断 与 AppStore比对
- javascript 判断当前浏览器版本
- 判断ios当前的sdk版本的方法
- 判断是否安装flash player及当前版本的JS代码
- C# 判断当前系统是XP还是WIN7 .获取当前系统版本
- 利用C#判断当前操作系统是否为Win8及其以上版本的系统
- 转:从AppStore获取一个iOS App的版本信息
- appStore检查版本更新与从app里跳到appstore评论页面
- JS判断是否安装flash player及当前版本
- 判断是否安装flash player及当前版本的JS代码
- js 判断当前浏览器的flash player 是否安装及版本
- 从AppStore获取一个iOS App的版本信息