iOS App 跳转到 AppStore
iOS设备上的App经常需要跳转到AppStore中进行升级或者是评价,这个过程其实很简单:给一个需要跳转的App对应的URL,然后调用跳转的方法openURL:
不过这个URL地址老是忘记,还是记下了比较好。
直接跳转
其实这个问题很简单,首先拿到你要跳转到的AppStore地址(URL)例如:
https://itunes.apple.com/cn/app/jie-zou-da-shi/id493901993?mt=8
然后将 http:// 替换为 itms-apps://
然后调用以下代码
NSString *str = [NSString stringWithFormat:@"itms-apps://itunes.apple.com/cn/app/jie-zou-da-shi/id493901993?mt=8"];
NSURL * url = [NSURL URLWithString:str];
if ([[UIApplication sharedApplication] canOpenURL:url])
{
[[UIApplication sharedApplication] openURL:url];
}
else
{
NSLog(@"can not open");
}
跳转到评论区
代码如下:
//去评分
NSString *str = [NSString stringWithFormat:@"itms-apps://itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id=%@",@"1006631751"];
NSURL * url = [NSURL URLWithString:str];
if ([[UIApplication sharedApplication] canOpenURL:url])
{
[[UIApplication sharedApplication] openURL:url];
}
else
{
NSLog(@"can not open");
}