ios 跳转AppStore的两种方法,以及遇到的坑
来源:互联网 发布:淘宝白底图片怎么拍 编辑:程序博客网 时间:2024/05/09 02:18
iOS跳转appStore的两种方法网上已经有很多的博客进行讲解了,主要是app内跳转相关网页,和跳出app,跳转到AppStore。相关的博客大家可以参看参考博客
为了防止参考博客实效,我把相关代码copy了一下,希望大家不要介意。
1,直接跳转
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"itms-apps://itunes.apple.com/app/id1018221712"]];
2,app 内跳转
- (void)btn:(UIButton *)btn{ if (btn.tag == 1) { //第一种方法 直接跳转 [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"itms-apps://itunes.apple.com/app/id1018221712"]]; }else{ //第二中方法 应用内跳转 //1:导入StoreKit.framework,控制器里面添加框架#import <StoreKit/StoreKit.h> //2:实现代理SKStoreProductViewControllerDelegate SKStoreProductViewController *storeProductViewContorller = [[SKStoreProductViewController alloc] init]; storeProductViewContorller.delegate = self;// ViewController *viewc = [[ViewController alloc]init];// __weak typeof(viewc) weakViewController = viewc; //加载一个新的视图展示 [storeProductViewContorller loadProductWithParameters: //appId @{SKStoreProductParameterITunesItemIdentifier : @"1018221712"} completionBlock:^(BOOL result, NSError *error) { //回调 if(error){ NSLog(@"错误%@",error); }else{ //AS应用界面 [self presentViewController:storeProductViewContorller animated:YES completion:nil]; } }]; }}#pragma mark - 评分取消按钮监听//取消按钮监听- (void)productViewControllerDidFinish:(SKStoreProductViewController *)viewController{ [self dismissViewControllerAnimated:YES completion:nil];}
看似很美好,但是测试的小伙伴发现在有的测试机器上,通过app内跳转的话,会一直白屏,没有正常的显示页面。打断点后发现:
[storeProductViewContorller loadProductWithParameters: //appId @{SKStoreProductParameterITunesItemIdentifier : @"1018221712"} completionBlock:^(BOOL result, NSError *error) { //回调 if(error){ NSLog(@"错误%@",error); }else{ //AS应用界面 [self presentViewController:storeProductViewContorller animated:YES completion:nil]; } }];
这个方法没有回调,而且没有任何的错误提示。经过半天排查无果后,我拿着可以正常跳转的页面的手机,和不正常跳转的页面的手机进行排查分析,首先从机型排查,发现出现不能正常跳转的页面的手机多种机型都存在;其次我有从操作系统进行排查,发现多个操作系统的手机都有出现无法正常跳转的情况。这两点都无法确定操作系统和机型是造成这种现象的原因。后来无意发现出现无法正常跳转的手机的appStore语言是英文,我猜测是不是登陆的appStore账号所在的国家和要跳转的app发布的市场不在一个国家导致的。为了验证我的猜测,我把不能正常跳转的手机,用国内的appStore账号登陆,重新运行程序,发现OK了。然后我又把可以正常跳转的手机,用国外的appStore账号登陆,重新运行程序,果然不能正常跳转了。所以啊。这个坑大家要注意:
跳转AppStore时,要保证appStore账号所在国家和app发布的国家是同一个国家。
阅读全文
0 0
- ios 跳转AppStore的两种方法,以及遇到的坑
- iOS 跳转AppStore的两种方法,应用内和直接跳转
- AppStore相关跳转的两种方式
- IOS界面跳转的两种方法
- 应用内跳转APPStore评论以及应用的方法
- iOS跳入Appstore的两种方式
- 在 iOS 应用中直接跳转到 AppStore 的方法
- 在 iOS 应用中直接跳转到 AppStore 的方法
- 在 iOS 应用中直接跳转到 AppStore 的方法
- IOS应用直接 跳转AppStore 的方法 IOS7以上
- 在 iOS 应用中直接跳转到 AppStore 的方法
- 在 iOS 应用中直接跳转到 AppStore 的方法
- 在 iOS 应用中直接跳转到 AppStore 的方法
- 在 iOS 应用中直接跳转到 AppStore 的方法
- 在 iOS 应用中直接跳转到 AppStore 的方法
- 在 iOS 应用中直接跳转到 AppStore 的方法
- 在 iOS 应用中直接跳转到 AppStore 的方法
- iOS 应用中直接跳转到 AppStore 的方法
- 百度地图加载百度js 出现 BMap is not defined
- Android 使用RecyclerView实现快速索引
- C++ BMP图片转换为PNG图片
- Json的格式化
- 为什么全新的Open Container Initiative标准是软件行业的里程碑?
- ios 跳转AppStore的两种方法,以及遇到的坑
- MVP设计模式
- CAS客户端请求重定向次数过多导致请求失败
- td文字太多撑开了table
- 文章标题
- 分布式协调服务zookeeper02-zookeeper核心工作机制以及api代码演示
- 禁用组合键
- Phpstrom 注册码
- Android Studio 清除项目无用资源