1.获取Apple ID
登录iTunes Connect, 在APP信息中,查看应用的Apple ID
2.获取本地应用版本号
- (NSString *)getBundleShortVersion {
// 本地应用信息
NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];
// 本地应用版本号
NSString *app_Version = [infoDictionary objectForKey:@"CFBundleShortVersionString"];
return app_Version;
}
3.请求AppStore中应用信息
请求链接: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];
// 正在销售的应用版本号
self.appStoreVersion = [[JSONDic objectForKey:@"result"] objectForKey:@"version"];
}
}];
[dataTask resume];
}
4.获取当前APP AppStore中的下载链接
在AppStore中找到应用,在"获取"中复制链接
5.跳转到AppStore更新应用
// 你的应用AppStore下载链接
NSURL *url = [NSURL URLWithString:@"https://itunes.apple.com/us/app/......."];
// 跳转
[[UIApplication sharedApplication] openURL:url];