ios - 如何链接到应用商店中的应用

我正在创建我的 iPhone 游戏的免费版本。我想在免费版本中有一个按钮,可以将人们带到应用商店中的付费版本。如果我使用标准链接

http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=300136119&mt=8

iPhone 首先打开 Safari,然后是应用商店。我用过其他直接打开应用商店的应用,所以我知道是可以的。

有什么想法吗?应用商店的 URL Scheme 是什么?

最佳答案

于 2016 年 2 月 2 日编辑

从 iOS 6 开始 SKStoreProductViewController类被介绍了。您可以在不离开应用的情况下链接应用。 Swift 3.x/2.xObjective-C 中的代码片段是 here .

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.


来自 News and Announcement For Apple Developers .

Drive Customers Directly to Your App on the App Store with iTunes Links With iTunes links you can provide your customers with an easy way to access your apps on the App Store directly from your website or marketing campaigns. Creating an iTunes link is simple and can be made to direct customers to either a single app, all your apps, or to a specific app with your company name specified.

To send customers to a specific application: http://itunes.com/apps/appname

To send customers to a list of apps you have on the App Store: http://itunes.com/apps/developername

To send customers to a specific app with your company name included in the URL: http://itunes.com/apps/developername/appname


补充说明:

您可以将 http:// 替换为 itms://itms-apps:// 以避免重定向。

请注意 itms:// 会将用户转到 iTunes 商店itms-apps:// 将它们发送到 App Store!

有关命名的信息,请参阅 Apple QA1633:

https://developer.apple.com/library/content/qa/qa1633/_index.html .

编辑(截至 2015 年 1 月):

itunes.com/apps 链接应更新至 appstore.com/apps。请参阅上面的 QA1633,它已被更新。一个新的QA1629建议使用以下步骤和代码从应用启动商店:

  1. 在您的计算机上启动 iTunes。
  2. 搜索您要链接的项目。
  3. 右键单击或按住 Control 单击 iTunes 中的项目名称,然后从弹出菜单中选择“复制 iTunes Store URL”。
  4. 在您的应用程序中,使用复制的 iTunes URL 创建一个 NSURL 对象,然后将此对象传递给 UIApplicationopenURL: 方法以在 App Store 中打开您的项目。

示例代码:

NSString *iTunesLink = @"itms://itunes.apple.com/app/apple-store/id375380948?mt=8";
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:iTunesLink]];

iOS10+:

 [[UIApplication sharedApplication] openURL:[NSURL URLWithString:iTunesLink] options:@{} completionHandler:nil];

swift 4.2

   let urlStr = "itms-apps://itunes.apple.com/app/apple-store/id375380948?mt=8"
    if #available(iOS 10.0, *) {
        UIApplication.shared.open(URL(string: urlStr)!, options: [:], completionHandler: nil)
        
    } else {
        UIApplication.shared.openURL(URL(string: urlStr)!)
    }

https://stackoverflow.com/questions/433907/

相关文章:

objective-c - 在 Objective-C 中,我如何测试对象类型?

ios - 如何以编程方式创建基本的 UIButton?

ios - 在 Objective-C 中通过 NSNotificationCenter 发送和接收

ios - UITextField 文本更改事件

ios - 如何在 Objective-C 中测试字符串是否为空?

ios - UITableViewCell,在滑动时显示删除按钮

objective-c - @synthesize 与 @dynamic,有什么区别?

objective-c - 定位服务在 iOS 8 中不起作用

objective-c - 如何将 NSString 转换为 NSNumber

ios - NS前缀是什么意思?