-2

breakpointing inside the callback and logging success shows false.

I added itms-apps to my plist: LSApplicationQueriesSchemes

and put this in my app delegate:

func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {
    return true
}

func moreTapped() {
    let url = NSURL(string: "itms-apps://itunes.com/developer/quantum-productions/id979315877")
    if #available(iOS 10.0, *) {
        UIApplication.shared.open(url! as URL, options: [:], completionHandler: {(success: Bool) in

        })
    } else {
        UIApplication.shared.openURL(url! as URL)
    }
}
rmaddy
  • 314,917
  • 42
  • 532
  • 579
quantumpotato
  • 9,637
  • 14
  • 70
  • 146

2 Answers2

3

You have the incorrect format for your URL, and you should use URL rather than NSURL in Swift.

This will open your developer page in the App Store app:

if let url = URL(string:"itms-apps://geo.itunes.apple.com/developer/quantum-productions/id979315877&mt=8") {
    UIApplication.shared.open(url, options: [:], completionHandler: nil)
}

There is no need to call canOpenURL for standard URL types such as http/s and itms.

Paulw11
  • 108,386
  • 14
  • 159
  • 186
  • Are you sure the scheme isn't `itms-apps`? I just tried it on mobile safari and at least from there I am not asked to open it in the AppStore app, but with itms-app I am. The domain correction etc you propose (using `geo`) seems correct. – Gero Jun 29 '18 at 07:39
  • Boinks, you edited right as I saved. Kudos, the answer is correct. :) – Gero Jun 29 '18 at 07:42
  • Itms also kind of works, but it opens the iTunes Store instead of the App Store, which isn't what is wanted. – Paulw11 Jun 29 '18 at 07:44
0

Apple just announced the appstore.com URLs.

**

https://developer.apple.com/library/ios/qa/qa1633/_index.html

**

To create an App Store Short Link, apply the following rules to your company or app name:

Remove all whitespace

Convert all characters to lower-case

Remove all copyright (©), trademark (™) and registered mark (®) symbols

Replace ampersands ("&") with "and"

Remove most punctuation (See Listing 2 for the set)

Replace accented and other "decorated" characters (ü, å, etc.) with their elemental character (u, a, etc.)

Leave all other characters as-is.

Listing 2 Punctuation characters that must be removed.

!¡"#$%'()*+,-./:;<=>¿?@[]^_`{|}~

Below are some examples to demonstrate the conversion that takes place.

App Name examples

Ocarina => http://appstore.com/ocarina

According to Apple's latest document items-apps: or items: won't not work. You need to use

appStoreLink = "https://itunes.apple.com/us/app/apple-store/id375380948?mt=8"

or

> SKStoreProductViewController

  • Example: https://www.techotopia.com/index.php/Making_Store_Purchases_with_the_SKStoreProductViewController_Class – GameLoading Jul 01 '18 at 11:55