Wednesday, October 7, 2015

canOpenURL Restrictions In iOS 9

iOS 9 has introduced a lesser-known limitation: It is not possible for apps to check if they can open an arbitrary URL anymore. Instead, only specific URL schemes can be checked: those that are included in the application's whitelist.

To create the whitelist, add an new array key called LSApplicationQueriesSchemes to Info.plist, then populate the array with all the schemes the app will test. Here is an example with the "uber" URL scheme:

<key>LSApplicationQueriesSchemes</key>
<array>
  <string>uber</string>
</array>


Note 1: The LSApplicationQueriesSchemes array items should only contain scheme names (without the trailing "://"), however canOpenURL still expects full URLs, like

BOOL uberInstalled = [app canOpenURL:[NSURL URLWithString:@"uber://"]];

Note 2: openURL is not affected by this change.

A nice writeup of the issue can be found here: http://awkwardhare.com/post/121196006730/quick-take-on-ios-9-url-scheme-changes.

No comments:

Post a Comment