iOS应用内打开App Store应用详情界面
来源:互联网 发布:js mailto 编辑:程序博客网 时间:2024/06/11 21:52
转自:http://blog.csdn.net/wave_1102/article/details/8564400
用iPhone浏览UC浏览器的“应用商店”时,发现可以直接在应用内打开App Store中的应用详情和下载页面。效果如下:
下面来看看怎么实现这个效果吧。
苹果官方文档 "SKStoreProductViewController Class Reference"里有如下介绍:
- A SKStoreProductViewController object presents a store that allows the user to purchase other media from the App Store. For example, your app might display the store to allow the user to purchase another app.
- To display a store, create a new SKStoreProductViewController object and set its delegate. Then, present the view controller modally from another view controller in your app. Your delegate dismisses the view controller when the user completes the purchase.
- To choose a specific product, call the loadProductWithParameters:completionBlock: method, passing the iTunes item identifier for the item you want to sell.
由上可知,通过Modal view方式弹出App Store商品详情页面。我按照文档说明,写了个例子。部分代码如下:
- - (void)openAppWithIdentifier:(NSString *)appId {
- SKStoreProductViewController *storeProductVC = [[SKStoreProductViewController alloc] init];
- storeProductVC.delegate = self;
- NSDictionary *dict = [NSDictionary dictionaryWithObject:appId forKey:SKStoreProductParameterITunesItemIdentifier];
- [storeProductVC loadProductWithParameters:dict completionBlock:^(BOOL result, NSError *error) {
- if (result) {
- [self presentViewController:storeProductVC animated:YES completion:nil];
- }
- }];
- }
另外,需要实现SKStoreProductViewControllerDelegate如下代理方法:
- #pragma mark - SKStoreProductViewControllerDelegate
- - (void)productViewControllerDidFinish:(SKStoreProductViewController *)viewController {
- [viewController dismissViewControllerAnimated:YES completion:^{
- [viewController release];
- }];
- }
可以这样调用:
- [self openAppWithIdentifier:@"383037733"];
这段代码即实现了上面图示的效果。
注:项目需要添加StoreKit框架,仅在iOS 6.0以上的设备中支持上述实现。
- Framework
- /System/Library/Frameworks/StoreKit.framework
- Availability
- Available in iOS 6.0 and later.
如果需要兼容6.0以下的设备,可以使用下面的代码(这种方式会跳出当前应用):
- - (void)outerOpenAppWithIdentifier:(NSString *)appId {
- NSString *urlStr = [NSString stringWithFormat:@"itms-apps://itunes.apple.com/us/app/id%@?mt=8", appId];
- NSURL *url = [NSURL URLWithString:urlStr];
- [[UIApplication sharedApplication] openURL:url];
- }
获取应用的链接方法可参考:http://itunes.apple.com/linkmaker
苹果官方文档:http://developer.apple.com/library/ios/#documentation/StoreKit/Reference/SKITunesProductViewController_Ref/Introduction/Introduction.html#//apple_ref/doc/c_ref/SKStoreProductViewController
0 0
- iOS应用内打开App Store应用详情界面
- iOS应用内打开App Store应用详情界面
- iOS—应用内打开App Store应用详情界面
- iOS应用内打开App Store应用详情界面
- iOS应用内打开App Store应用详情界面
- iOS应用内打开App Store应用详情界面
- iOS应用内打开App Store应用详情界面
- iOS在应用内打开App Store
- 应用内打开App Store评分
- iOS应用内跳转到App Store详情页或者评论页
- Unity3D-应用内打开AppStore某个应用详情方法(iOS应用内下载、应用内评星)
- 在 iOS 应用调用 App Store 显示指定应用的详情
- iOS应用内跳转至App Store 以及获取App Store内最新版本号
- iOS 6 SDK: 在应用内展示App Store
- iOS 6 SDK: 在应用内展示App Store
- iOS 6 SDK: 在应用内展示App Store
- iOS 6 SDK: 在应用内展示App Store
- iOS 6 SDK: 在应用内展示App Store
- 推荐一个Linux远程桌面工具
- centos 6.5 安装gitlab安装需注意的问题
- 1111111
- C/C++ struct初始化/复制/内存分配技巧
- mongoDB图形化界面mongoVUE 的破解方法
- iOS应用内打开App Store应用详情界面
- Python特殊语法:filter、map、reduce、lambda [转]
- 数据流图的画法
- linux 安装 Jdk 1.6.45
- ubuntu/centos环境下玩android系统(一): 从编译android开始!
- android 4.0.3最新源码下载编译
- 通过shell进行数学运算的多种方式
- opencv读取图片,视屏,摄像头
- JDBC学习笔记(1)-----温故jdbc