1、应用内部跳转到Appstore
1、跳转到应用详情
[[UIApplication sharedApplication]openURL:[NSURL URLWithString:@"itms-apps://itunes.apple.com/app/id1061880281"]];
其中 @"itms-apps://itunes.apple.com/app/id1061880281"为拼接地址,1061880281为应用在Appstore注册上线时产生的唯一ID
2、跳转到评论
[[UIApplication sharedApplication]openURL:[NSURL URLWithString:@"itms-apps://itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?id=1232138855&pageNumber=0&sortOrdering=2&type=Purple+Software&mt=8"]];
注:由于iOS11对应用商店进行了重新设计,使用该链接在iOS11系统上会发现找不到应用。解决办法:判断系统版本,如果系统版本大于iOS11,跳转上1链接即可
2、扫描二维码跳转到appstore
https://itunes.apple.com/app/id1061880281 ,用这个地址生成二维码即可
但是有可能会碰到多国语言问题,你会发现在其他语言下用安卓设备扫描二维码会进入itunes,而默认展示出来的界面确是英文环境,这是你只需要在 https://itunes.apple.com/app/id1061880281 修改为如下:
例如中文:https://itunes.apple.com/cn/app/id1061880281
例如日文:https://itunes.apple.com/jp/app/id1061880281
等等...也就是在https://itunes.apple.com/后面加上国家的简写国际字符即可
3、检测新版本升级跳转到AppStore
注:这个功能只有写在应用每次启动时检测,如果在设置界面留有检测更新入口,上架时审核会被苹果拒绝,苹果是不允许在AppStore之外的方式升级的
-(void)checkVersion {
NSString *path = [[NSString alloc] initWithFormat:@"http://itunes.apple.com/lookup?id=%@",@"1061880281"];
NSURL *url = [NSURL URLWithString:path];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:10];
[request setHTTPMethod:@"POST"];
NSOperationQueue *queue = [NSOperationQueue new];
[NSURLConnection sendAsynchronousRequest:request queue:queue completionHandler:^(NSURLResponse *response,NSData *data,NSError *error){
NSMutableDictionary *receiveStatusDic=[[NSMutableDictionary alloc]init];
if (data) {
NSDictionary *receiveDic = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableLeaves error:nil];
if ([[receiveDic valueForKey:@"resultCount"] intValue]>0) {
[receiveStatusDic setValue:@"1" forKey:@"status"];
[receiveStatusDic setValue:[[[receiveDic valueForKey:@"results"] objectAtIndex:0] valueForKey:@"version"] forKey:@"version"];
}else{
[receiveStatusDic setValue:@"-1" forKey:@"status"];
}
}else{
[receiveStatusDic setValue:@"-1" forKey:@"status"];
}
[self performSelectorOnMainThread:@selector(receiveData:) withObject:receiveStatusDic waitUntilDone:NO];
}];
}
- (void)receiveData:(id)sender {
NSString *serverVersion = [sender objectForKey:@"version"]; //获取版本号
//获取应用当前版本
NSString *currentVersion = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"];
// 服务器版本号大于当前版本号
if ([serverVersion compare:currentVersion options:NSNumericSearch] == NSOrderedDescending) {
// 有新版本,执行升级操作
} else {
// 没有检测到新版本
}
}