Search code examples
iosswiftxcodecocoa-touchapp-store

Open AppStore through button


Could you guys help me to translate the following code into Swift?

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"itms://itunes.apple.com/de/app/x-gift/id839686104?mt=8&uo=4"]];

(or do I have to take this link: itms://itunes.apple.com/app/id839686104?)


Solution

  • Here. But I highly suggest you learn the basics of Swift!

    UIApplication.sharedApplication().openURL(NSURL(string: "itms://itunes.apple.com/de/app/x-gift/id839686104?mt=8&uo=4")!)
    

    If you wanna open the AppStore in Swift 5:

    if let url = URL(string: "itms-apps://itunes.apple.com/app/id1629135515") {
        UIApplication.shared.open(url)
    }