iOS应用内跳转到App Store详情页或者评论页

要想在App内跳转到特定App的详情页或者评论页,首先需要获取到App的id。在iTunes Connect网站上登陆之后,选择“我的App”,然后点击某个特定的App进入,在App信息的综合信息中,会有一个“Apple ID”的条目,就是一串数字,这个就是对应App的id了。另外在App信息的额外信息中,点击“在 App Store 中查看”会跳转到一个特定链接的页面,这个链接在下文中也会用到,这个链接会大概是这样的"https://itunes.apple.com/us/app/fa-bu-ce-shi/idxxxxxxxxx?l=zh&ls=1&mt=8"。

一、iOS应用内跳转到App Store详情页有两种方式:

1、跳转到App Store应用中对应App的详情页

(1)直接使用上文中获取到的链接,通过openURL方法实现,即

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"https://itunes.apple.com/us/app/fa-bu-ce-shi/idxxxxxxxxx?l=zh&ls=1&mt=8"]];

将上述链接中的https://更换为itms://或者itms-apps://也可以实现跳转效果,但itms://开头的链接是跳转到iTunes Store应用中,https://与itms-apps://开头的链接是跳转到App Store应用中。

(2)利用上文获取到的appId拼接成链接“itms-apps://itunes.apple.com/app/idxxxxxxxxx”,也通过openURL方法实现,即

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"itms-apps://itunes.apple.com/app/idxxxxxxxxx"]];

2、在App内部跳转到指定App详情页

步骤为:

(1)导入相应的框架

#import <StoreKit/StoreKit.h>

(2)使当前控制器遵守协议SKStoreProductViewControllerDelegate

(3)在应当跳转方法中实现下列代码,即创建SKStoreProductViewController控制器,设置代理,加载相应内容,在加载完成的回调中,等加载完成之后使用present的方式将视图控制器呈现出来。

    SKStoreProductViewController *storeProductVC = [[SKStoreProductViewController alloc]init];

    storeProductVC.delegate = self;

    [storeProductVC loadProductWithParameters:@{SKStoreProductParameterITunesItemIdentifier:@xxxxxxxxx} completionBlock:^(BOOL result, NSError * _Nullable error) {

        if (error) {

            NSLog(@"%@",[error localizedDescription]);

        } else {

            NSLog(@"加载完成");

            [self presentViewController:storeProductVC animated:YES completion:^{

                NSLog(@"界面弹出完成");

            }];

        }

    }];

(4)实现SKStoreProductViewControllerDelegate的代理方法,即

- (void)productViewControllerDidFinish:(SKStoreProductViewController *)viewController{

    NSLog(@"用户请求页面弹回");

    [self dismissViewControllerAnimated:YES completion:^{

        NSLog(@"页面弹回完成");

    }];

}

当用户点击取消时,会执行此代理方法,将控制器弹回即可。

     二、iOS应用内跳转到App Store评论页有iOS7之前和之后的区别:跳转方法一样,但是链接不同,即

(1)iOS7之前

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"itms-apps://ax.itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id=xxxxxxxxx"]];//iOS7之前跳转到App评论页

(2)iOS7之后

    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?id=xxxxxxxxx&pageNumber=0&sortOrdering=2&type=Purple+Software&mt=8"]];//iOS7之后跳转到App评论页





  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值