Launching App Store from App in Swift

前端 未结 9 993
情深已故
情深已故 2020-12-31 01:43

I am creating an app, and I have a banner which promotes my other app. This is my code:

var barsButton : UIButton = UIButton(frame: CGRectMake((self.view.bou         


        
相关标签:
9条回答
  • 2020-12-31 02:28

    Swift 3 - XCode 8.2.1

    UIApplication.shared.openURL(URL(string: "itms-apps://itunes.apple.com/app/id" + appStoreAppID)!)
    
    0 讨论(0)
  • 2020-12-31 02:39

    Use just the short "itms://".

    For Swift 3 this is the snippet:

    UIApplication.shared.openURL(URL(string: "itms://itunes.apple.com/app/id" + appStoreAppID)!)
    

    I hope this helps someone.

    Cheers.

    P.S. @Eric Aya was ahead of the time :)

    0 讨论(0)
  • 2020-12-31 02:40

    Just by following older answers I couldn't make it work, so here I post my complete solution:

    if let url  = NSURL(string: "itms-apps://itunes.apple.com/app/id1234567890"), 
       UIApplication.shared.canOpenURL(url) {
        
      UIApplication.shared.openURL(url)
        }
    }
    
    0 讨论(0)
提交回复
热议问题