用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

iOS应用内打开App Store应用详情界面相关推荐

  1. html 链接到 appstore,如何在微信浏览器内打开App Store链接

    微信浏览器是不支持打开 App Store 页面的,不知道微信为什么这么做. 比如你页面写 download ,在微信浏览器点击是没有反应的,但是如果是其他的链接地址,如百度就没有问题. 但是,如果在 ...

  2. 微信浏览器内打开App Store链接

    将页面的代码写为:<a href="http://mp.weixin.qq.com/mp/redirect?url=http://itunes.apple.com/cn/app/gua ...

  3. 实现微信浏览器内打开App Store链接

    微信浏览器是不支持打开App Store 页面的,不知道微信为什么这么做.比如你页面写 <a href="http://itunes.apple.com/us/app/id903800 ...

  4. 微信浏览器内打开App Store链接,并跳转到App指定安装页面

    id1234567 代表'id' + appid,这里的是 测试的数据, 在html中加上这个链接 https://itunes.apple.com/cn/app/id1234567 可以唤起 苹果商 ...

  5. Url scheme 方式 打开App Store和应用商店

    Url scheme 方式 打开App Store和应用商店 iOS打开方式 itms-apps://itunes.apple.com/app/id应用ID 例子:微信的应用ID 为 41447812 ...

  6. iOS和Android手机浏览器链接打开app store或应用市场下载软件

    iOS和Android手机浏览器链接打开app store或应用市场下载软件 1.Android主流手机跳转链接 // androidId 如:com.xxx.app// oppo oppomarke ...

  7. 如何在iOS 6 时代的App Store中推广

    下载原文:如何在iOS_6_App_Store_脱颖而出 1 winning strategies for iOS 6 App Store Optimization MIX 智游汇2012 10 如何 ...

  8. iOS提交应用至App Store流程及真机调试 一,证书、配置文件

    前言:你要有苹果开发人员账号,我用的是个人账号.其次xcode为xcode 7,因为xcode 7须要 os x 系统 10.11 或更高的版本号, 所以os x 系统也须要 10.11 或更高的版本 ...

  9. 微信中打开app store连接

    微信浏览器是不支持打开App Store 页面的.比如你页面写 <a href="http://itunes.apple.com/us/app/ id867985717″>下载取 ...

最新文章

  1. 用surfaceView实现高性能动画
  2. html实战例子: 点击图片超链接跳转
  3. 解读Junit的@Test注解,避免initializationerror
  4. Circle-Progress-View
  5. C和指针之函数之求参数列表中的最大值
  6. SQL Server群集共享存储迁移
  7. 【hadoop】Yarn【label-based scheduling】实战总结
  8. 现代软件工程 第3-6章 作业
  9. vue显示农历_vue农历日历
  10. 【知识兔】自学Excel之4:窗口视图控制
  11. java Io,读写文件拒绝访问
  12. SpringBoot整合Thymeleaf(22)
  13. 如何成为一个牛逼的程序员?
  14. ubuntu uninstall
  15. CYK 算法 Python 实现
  16. 计算机提示无法识别usb,电脑提示“无法识别的USB设备”如何解决?
  17. 计算机组成原理第二章笔记---计算机进化与性能
  18. 关于树叶的活动设计_小学生“树叶探秘”主题活动方案
  19. 【翻译】WF从入门到精通(第十七章):关联及本地主机通信
  20. 令人肝肠寸断的100个签名

热门文章

  1. Python语法对空格的严格要求
  2. Excel如何破解vba的宏密码
  3. 香港首家Gap奥特莱斯在东荟城名店仓开业
  4. 与IT相关的英文缩写
  5. python - 集合:华为笔试题
  6. 微信智慧外链接微信小程序源码下载,支持多端转换,致力打造(微信)小程序生态的基础必需品
  7. 案例3-1-1 构建旁挂二层组网隧道转发WLAN
  8. 图像处理-离散傅里叶变换-数字图像处理第三版第四章内容
  9. php_game1姓名大战
  10. 前端阿里巴巴矢量图标库的使用