12

In iOS 9 apps can't use canOpenURL to check if application installed or not.

If your (iOS 9.0 or later) app calls this method using a scheme you have not declared, the method returns false, whether or not an appropriate app for the scheme is installed on the device.

but I am wondering how facebook app succeed to direct the user to appstore if the application is not installed , or to open target application if it's installed !

facebook can't list all apps in LSApplicationQueriesSchemes !

Thanks

Tejas Ardeshna
  • 4,343
  • 2
  • 20
  • 39
david
  • 3,310
  • 7
  • 36
  • 59
  • may be its an exception apple made, because apple has option for Facebook settings specially in settings app. But where you need this for your application. I mean what you want to achieve actually? – Mahesh Agrawal Sep 13 '16 at 01:50

1 Answers1

1

From canOpenURL: documentation:

Unlike this method, the openURL: method is not constrained by the UIDefaultLaunchStoryboard requirement: If an app that handles a scheme is installed on the device, the openURL: method works, whether or not you have declared the scheme.

So, they do the following:

1) Try to call openURL: with fb-compliant urls, for example fb[app-id]://authorize... until it returns true (I have checked it, they are calling a lot of urls, for example fb[app-id]lite, fb[app-id]mac, fb[app-id]paid, fb[app-id]green, etc). If it succedes, target app opens.

2) If there is no success with calling openURL:, they try to call canOpenURL: with http://itunes.apple.com/app/... url and then call openURL: with same url. User is redirected to App Store.

Roman Ermolov
  • 7,898
  • 5
  • 27
  • 35