iOS 利用SKStoreProductViewController 应用内评分

iOS6以后,苹果提供了在应用内部打开App Store中某一个应用下载页面的方式,提供了 SKStoreProductViewController类进行支持

1、添加 #import

2、添加代理 SKStoreProductViewControllerDelegate

3、添加代码

- (void)evaluate

{

        Class isAllow = NSClassFromString(@"SKStoreProductViewController");

        if (isAllow != nil && ![[UIDevice currentDevice].model  isEqualToString:@"iPhone Simulator"])

        {

                [self showLoadingView];

                __weak __typeof(self) weakself = self;

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

                 product.delegate = self;

                [product loadProductWithParameters:@{SKStoreProductParameterITunesItemIdentifier:@"APP ID"} completionBlock:^(BOOL result, NSError *error) {

                __strong __typeof(weakself) strongself = weakself;

                [strongself hideLoadingView];

                if (error) {

                        NSLog(@"error = %@ with userinfo = %@",error,[error userInfo]);

                } else {

                        [strongself presentViewController:product animated:YES completion:nil];

                }

                }];

        }

        else

        {

                [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@""]];

        }

}

- (void)productViewControllerDidFinish:(SKStoreProductViewController *)viewController

{

        [self dismissViewControllerAnimated:YES completion:nil];

}

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容