Edited on 2016-02-02
(编辑于2016-02-02)
Starting from iOS 6 SKStoreProductViewController class was introduced.
(从iOS 6开始,介绍了SKStoreProductViewController类。)
You can link an app without leaving your app. (您可以在不离开应用的情况下关联应用。)
Code snippet in Swift 3.x/2.x and Objective-C is here . (Swift 3.x / 2.x和Objective-C中的代码片段就在这里 。)
A SKStoreProductViewController object presents a store that allows the user to purchase other media from the App Store.
(SKStoreProductViewController对象提供了一个商店,允许用户从App Store购买其他媒体。)
For example, your app might display the store to allow the user to purchase another app. (例如,您的应用可能会显示商店以允许用户购买其他应用。)
From News and Announcement For Apple Developers .
(来自Apple开发者的新闻和公告 。)
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.
(使用iTunes链接在App Store上直接将您的应用程序驱动到您的应用程序通过iTunes链接,您可以直接从您的网站或营销活动中为您的客户提供在App Store上访问您的应用程序的简便方法。)
Additional notes:
(补充说明:)
You can replace http://
with itms://
or itms-apps://
to avoid redirects.
(您可以使用itms://
或itms-apps://
替换http://
itms-apps://
以避免重定向。)
Please note that itms://
will send the user to the iTunes store and itms-apps://
with send them to the App Store!
(请注意 itms://
会将用户发送到iTunes商店和itms-apps://
并将其发送到App Store!)
For info on naming, see Apple QA1633:
(有关命名的信息,请参阅Apple QA1633:)
https://developer.apple.com/library/content/qa/qa1633/_index.html .
(https://developer.apple.com/library/content/qa/qa1633/_index.html 。)
Edit (as of January 2015):
(编辑(截至2015年1月):)
itunes.com/apps links should be updated to appstore.com/apps.
(itunes.com/apps链接应更新为appstore.com/apps。)
See QA1633 above, which has been updated. (见上面的QA1633,已经更新。)
A new QA1629 suggests these steps and code for launching the store from an app: (新的QA1629建议从应用程序启动商店的这些步骤和代码:)
- Launch iTunes on your computer.
(在您的计算机上启动iTunes。)
- Search for the item you want to link to.
(搜索要链接到的项目。)
- Right-click or control-click on the item's name in iTunes, then choose "Copy iTunes Store URL" from the pop-up menu.
(右键单击或按住Control键并单击iTunes中项目的名称,然后从弹出菜单中选择“复制iTunes Store URL”。)
- In your application, create an
NSURL
object with the copied iTunes URL, then pass this object to UIApplication
' s openURL
: method to open your item in the App Store. (在您的应用程序中,使用复制的iTunes URL创建NSURL
对象,然后将此对象传递给UIApplication
的openURL
:方法,以在App Store中打开您的项目。)
Sample code:
(示例代码:)
NSString *iTunesLink = @"itms://itunes.apple.com/app/apple-store/id375380948?mt=8";
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:iTunesLink]];
Swift 4.2
(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)!)
}