iOS 版本更新
获取当前版本、比较线上版本、然后决定是否更新 当前版本: //////获取 info.plist文件内容 NSDictionary *infoDic = [[NSBundle mainBundle] infoDictionary]; ////获取general 里的 build NSString *appVersion = [infoDic objectForKey:@"CFBundleVersion"]; ////获取general 里的 version NSString *currentVersion = [infoDic objectForKey:@"CFBundleShortVersionString"]; 线上版本: 1、POST请求方式:http://itunes.apple.com/search?term=你的应用程序名称&entity=software 2、http://itunes.apple.com/lookup?id=“tunes connect里的 Apple ID” 用2获取: NSDictionary *dicVersion = [NSJSONSerialization JSONObjectWithData:dataes options:0 error:nil]; NSMutableArray *arrayVersion = [NSMutableArray arrayWithArray:[dicVersion objectForKey:@"results"]]; NSDictionary *resultsVersion = [arrayVersion objectAtIndex:0]; NSString *lastVersion = [resultsVersion objectForKey:@"version"]; NSString *trackViewUrl = [resultsVersion objectForKey:@"trackViewUrl"]; 决定是否更新: if ([arrayVersion count]) { if (![lastVersion isEqualToString:currentVersion]) { ////更新 }else{ ////不更新 } } ////官方文档: www.apple.com/itunes/affiliates/resources/documentation/itunes-store-web-service-search-api.htm ////////更新提醒: - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex { if (alertView.tag==888) { if (buttonIndex==0) { NSURL *url = [NSURL URLWithString:trackViewUrl]; [[UIApplication sharedApplication]openURL:url]; } } }
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。