URL地址: https://itunes.apple.com/cn/lookup?id=你的AppId
參數(shù)AppId指的是你在APP在創(chuàng)建后的唯一標(biāo)識(shí),在iTunes Connect里可以查找到此信息虐骑。
tmp58d9db39.png
獲取線上版本信息(字段---version)
//獲取當(dāng)前bundle中的版本號(hào)
NSDictionary *infoDic = [[NSBundle mainBundle] infoDictionary];
NSString *currentVersion = [infoDic objectForKey:@"CFBundleShortVersionString"];
//獲取App Store中當(dāng)前APP的版本號(hào)
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
[manager POST:urlStr parameters:nil success:^(AFHTTPRequestOperation * _Nonnull operation, id _Nonnull responseObject) {
NSArray *array = responseObject[@"results"];
NSDictionary *dict = [array lastObject];
NSLog(@"線上版本:%@", dict[@"version"]);
NSString *lineVersion = dict[@"version"];
if ([lineVersion compare:currentVersion options:NSNumericSearch] == NSOrderedDescending)
{
//appstore 版本更高
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"" message: [NSString stringWithFormat:@" 新版本 %@ 已發(fā)布 ! ", lineVersion] delegate:self cancelButtonTitle:@"以后再說(shuō)" otherButtonTitles: @"馬上更新", nil];
[alert show];
NSLog(@"線上版本:%@ 更高", lineVersion);
}
else
{
NSLog(@"當(dāng)前版本:%@ 更高", currentVersion);
}
//返回json中的trackViewUrl就是App Store中當(dāng)前APP的下載頁(yè)面
self.trackViewUrl = dict[@"trackViewUrl"];
} failure:^(AFHTTPRequestOperation * _Nullable operation, NSError * _Nonnull error) {
NSLog(@"錯(cuò)誤 : %@",error);
}];
//跳轉(zhuǎn)App Store頁(yè)面進(jìn)行下載
[[UIApplication sharedApplication]openURL:[NSURL URLWithString:self.trackViewUrl]];