Opening the Apple TV App Store

不问归期 提交于 2019-12-17 23:23:40

问题


Trying to build a tvOS app and one of the use cases I have is to be able to link off and open another app in the Apple TV App Store directly on a button click. Can someone please share a code snippet to enable this?


回答1:


I have figured this out by examining the device console output. The trick is to use the com.apple.TVAppStore scheme instead of itms-apps. Example (Swiss App Store):

com.apple.TVAppStore://itunes.apple.com/ch/app/youtube/id544007664?mt=8

In fact, the https scheme is also working, but it's then transformed into com.apple.TVAppStore anyway.




回答2:


Just tested this on tvOS:

if let appStoreURL = NSURL(string: "https://itunes.apple.com/us/app/wee-puzzles/id1035425291?mt=8") {
    UIApplication.sharedApplication().openURL(appStoreURL)
}

It works and opens the App Store page of your app on Apple TV. It's the same as iOS.




回答3:


Unfortunately this is not possible with the current tvOS.

On iOS, as advised by Apple in QA1629, we would do:

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

The above request goes through Safari which does not exist on tvOS. Therefore, it won't work.

However, Custom URL Schemes are supported on tvOS which might help at least a bit.




回答4:


Should be possible using SKStoreProductViewController in StoreKit. But apparently, that too is _TVOS_PROHIBITED.

SKStoreProductViewController Class Reference




回答5:


Yes, it works ! Just use the link provided by Apple's link maker. For example:

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"https://geo.itunes.apple.com/fr/app/math-champions-jeux-calcul/id561572290?mt=8"]]

Do not modify the link by removing the language or the name of the app like you can on iOS.




回答6:


You can use the URL you get from iTunes. For example:

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"https://geo.itunes.apple.com/fr/app/math-champions-jeux-calcul/id561572290?mt=8"]]

Similar to what the above answers said. But, in order for this to work, your app must be set up as a universal purchase for iOS and tvOS, which is very easy to set up: Universal Purchase of iOS and tvOS Apps.




回答7:


This is the solution for Swift 4: Replace XXXXXXXwith your app id. With this solution its possible to create an appstore link for a not yet released app because only the app id (known from appstore connect) is needed.

guard let tvOSAppStoreUrl = URL(string: "com.apple.TVAppStore://itunes.apple.com/app/idXXXXXXX?mt=8") else {
  return
}

UIApplication.shared.open(url, options: [:], completionHandler: nil)


来源:https://stackoverflow.com/questions/33163334/opening-the-apple-tv-app-store

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!