1.獲取Apple ID
登錄iTunes Connect, 在APP信息中,查看應(yīng)用的Apple ID
2.獲取本地應(yīng)用版本號(hào)
- (NSString *)getBundleShortVersion {
// 本地應(yīng)用信息
NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];
// 本地應(yīng)用版本號(hào)
NSString *app_Version = [infoDictionary objectForKey:@"CFBundleShortVersionString"];
return app_Version;
}
3.請(qǐng)求AppStore中應(yīng)用信息
請(qǐng)求鏈接:https://itunes.apple.com/lookup?id=(獲取的Apple ID)
- (void)getAppStoreVersion {
NSURL *url = [NSURL URLWithString:@"https://itunes.apple.com/lookup?id=533314804"];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionTask *dataTask = [session dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
if (data) {
NSString *JSONStr = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
NSLog(@"JSONStr IS %@",JSONStr);
NSDictionary *JSONDic = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingAllowFragments error:&error];
// 正在銷售的應(yīng)用版本號(hào)
self.appStoreVersion = [[JSONDic objectForKey:@"result"] objectForKey:@"version"];
}
}];
[dataTask resume];
}
4.獲取當(dāng)前APP AppStore中的下載鏈接
在AppStore中找到應(yīng)用,在"獲取"中復(fù)制鏈接
5.跳轉(zhuǎn)到AppStore更新應(yīng)用
// 你的應(yīng)用AppStore下載鏈接
NSURL *url = [NSURL URLWithString:@"https://itunes.apple.com/us/app/......."];
// 跳轉(zhuǎn)
[[UIApplication sharedApplication] openURL:url];