Opening the Apple TV App Store

前端 未结 7 1119
南旧
南旧 2020-12-13 22:06

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 p

相关标签:
7条回答
  • 2020-12-13 22:34

    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)
    
    0 讨论(0)
  • 2020-12-13 22:37

    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.

    0 讨论(0)
  • 2020-12-13 22:40

    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.

    0 讨论(0)
  • 2020-12-13 22:41

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

    SKStoreProductViewController Class Reference

    0 讨论(0)
  • 2020-12-13 22:45

    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.

    0 讨论(0)
  • 2020-12-13 22:50

    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.

    0 讨论(0)
提交回复
热议问题