iOS开发 判断您当前app版本和升级

首先我们可以根据info.plist文件中的bundle version中获取

NSDictionary *infoDic = [NSBundle mainBundle] infoDictionary];
NSSting *currentVersion = [infoDic objectForKey:@"CFBundleShortVersionString"];

其次,请求APP的相关数据
https://itunes.apple.com/lookup?id=XXX(其中XXX是你的app的商店ID),你过去到的数据是json数据
进行接卸,将version的数据根你从info.plist获取的数据进行比较!

fileSizeBytes: “XXXXXXX”
sellerUrl: “http://cineplx.sscac.com.cn/"
taeckCensoredName //审查名称
trackContentRating: “12+” //评级
currency: “USD”
wrapperType: “software”
version: “1.0.0” //版本
artistID: XXX
artistName: XXX

代码

-(void)judgeAPPVersion
{
//  http://itunes.apple.com/lookup?id=XXX
   NSString *urlStr = @"https//itunes.apple.com/lookup?id=xxx";
   NSURL *url = [NSURL URLWithString:urlStr];
   NSURLRequest *req = [NSURLRequest requestWithURL:url];
  [NSURLConnection connectionWithRequset:req delegate:self];
}
-(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data{
NSError *error;
id jsonObject = [NSJSONSeralization JSONObjectWithData:data options:    NSJSONReadingAllowFragments error:&error];
NSDictionary *appInfo =(NSDictionary *)jsonObject;
 NSArray *onfoContent =[appInfo objectForKey:@"results"];
  NSString *version = [[infoContent objectAtIndex:0]objectForKey:@"version"];
  NSLog(@"商店的版本是 %@",version);
  NSDictionary *infoDic = [[NSBundle mainBundle]infoDictionary];
  NSString *currentVersion =[infoDic objectForKey:@"CFBundleShortVersionSring"];
  NSLog(@"当前版本是%@",currentVersion);
}

if(![version isEqualToString:currentVersion])
  {
UIAlertView *alert = [UIAlertView alloc]initWithTitle:nil message:@"商店有新的版本了" delegate:nil cancelButtonTitle:@"YES" otherButtonTitles:nil];
[alert show];

  }
}    

跳转到商店更新app的接口的按钮
[UIApplication sharedApplication] openURL:[NSURL URLWithString:trackViewUrl]];