Search code examples
iosfacebook-messengerinfo.plistuiapplication

canOpenURL always return false even if I specify Launch Service Keys


I am trying to detect if a specific app is installed and according to the docs, the canOpenURL method could help. Also I am on iOS 11, and according to the docs, for > iOS 9, this is important thing to keep in mind:

Important If your app is linked on or after iOS 9.0, you must declare the URL schemes you want to pass to this method. Do this by adding the LSApplicationQueriesSchemes key to your app's Info.plist file. If you call this method for a scheme not declared using that key, this method always returns false, whether or not an appropriate app is installed. To learn more about the key, see LSApplicationQueriesSchemes.

Means that in Info.plist, I should add something like this:

<key>LSApplicationQueriesSchemes</key>
<array>
    <string>messenger</string>
</array>

So far, so good. But when I try to detect if app is installed, like this:

if( [[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"messenger://"]]){}

I still get false... What am I missing here ?


Solution

  • Facebook Messenger uses:

    <string>fb-messenger-api</string>
    

    as its URL Scheme.