5

I am using apple's canOpenURL: and openURL: methods to detect & open other application. But as these methods are deprecated in iOS9, They returns NO.

Is there any alternate to manage this?

Thanks

user2864740
  • 60,010
  • 15
  • 145
  • 220
shivam
  • 1,148
  • 1
  • 12
  • 28
  • My Xcode 7 beta 3 documentation does not mark those methods as deprecated in iOS 9?!? – trojanfoe Jul 17 '15 at 07:55
  • I'm also interested to know where it says it has been deprecated. Please can you share wherever you read this. – Popeye Jul 17 '15 at 07:57
  • 3
    __who said it is deprecated in iOS9?__ both are working fine in _beta-3_, no sign of any deprecation of neither `–canOpenURL:` nor `–openURL:`... – holex Jul 17 '15 at 11:26
  • yeah so this functionality is not disabled. as per @tikhonov answer, Just whitelist the application in plist file to which you want to open from your application. – shivam Jul 17 '15 at 11:31

3 Answers3

7

You need to provide "whitelist" to your plist

<key>LSApplicationQueriesSchemes</key>
<array>
 <string>urlscheme</string>
 <string>urlscheme2</string>
 <string>urlscheme3</string>
 <string>urlscheme4</string>
</array> 

See for more details

iOS 9 has made a small change to the handling of URL scheme.

More details

Community
  • 1
  • 1
Tikhonov Aleksandr
  • 13,945
  • 6
  • 39
  • 53
  • As a point of clarification, do NOT include "://" in the string of a specific app to be whitelisted in the LSApplicationQueriesSchemes array, i.e. "comgooglemaps://". If you do include "://" canOpenUrl: will return NO and provide the "This app is not allowed to query for scheme xxx" syslog/error. However, when you make the actual call of canOpenUrl: you must still include the colon i.e. canOpenUrl:@"comgooglemaps:". – EmphaticArmPump Jul 28 '15 at 18:06
2

Here you can find some information.

as the article said:

Up until iOS 9, apps have been able to call these methods on any arbitrary URLs. Starting on iOS 9, apps will have to declare what URL schemes they would like to be able to check for and open in the configuration files of the app as it is submitted to Apple. This is essentially a whitelist that can only be changed or added to by submitting an update to Apple. It appears that certain common URLs handled by system apps, like “http”, “https”, do not need to be explicitly whitelisted.

In short: Apple wants to prevent apps from being able to scan a user's device and know which apps are installed

So to answer to your question: actually there is no solution, because apple want exactly to prevent this kind of behaviour

Max_Power89
  • 1,710
  • 1
  • 21
  • 38
1

In some contexts, if you need to open arbitrary deeplinks, the Universal App Links can be a solution: you point to the website of the app (which needs to implement this behaviour) and iOS 9 will automatically deeplink to the adhoc app.

MonsieurDart
  • 6,005
  • 2
  • 43
  • 45