1. 程式人生 > >iOS 9: -canOpenURL: failed for URL #

iOS 9: -canOpenURL: failed for URL #

AppAvailability Bug
appAvailability.check returns alway error callback.

iOS 9 Error in Xcode
-canOpenURL: failed for URL: "<scheme>://" - error: "This app is not allowed to query for scheme <scheme>"

Explanation
Apple changed the canOpenURL method on iOS 9. Apps which are checking for URL Schemes have to declare these Schemes as it is submitted to Apple. The article 

Quick Take on iOS 9 URL Scheme Changes expains the changes in detail.

Solution: Add URL Schemes to the Whitelist
Simply open your app's .plist (usually platforms/ios/<appname>/<appname>-Info.plist) with an editor and add the following code with your needed Schemes.

<key>LSApplicationQueriesSchemes</key
> <array> <string>twitter</string> <string>whatsapp</string> </array>