37
votes

I've updated to Xcode 7 and the latest iOS SDK. I've added the appropriate entries in my app's plist:

enter image description here

My app's Facebook login works fine on device. However, on iOS 9 simulator, I'm getting:

-canOpenURL: failed for URL: "fbauth2:///" - error: "(null)"

And login is not working. I've seen facebook login issue - canOpenURL: failed for URL: "fbauth2:///" - error: "(null)" but I have FBSDKCoreKit framework. I've also seen Facebook SDK 4.5 IOS 9 but it's answer doesn't solve my problem.

Why am I getting this error on simulator and not on device even though I've done the checklist at https://developers.facebook.com/docs/ios/ios9?

9
I have same question. Do you have solution?Jimmy Wang
There seems to be a bug with the iOS Simulator cause it works on the device as expected!Daniel
Exactly the same thing here but I do notice that if you leave the SafariViewController window (which is blank in my case) up long enough it eventually crashes SafariViewController with the following message: 'UserInfo={NSDebugDescription=The connection to service named com.apple.uikit.viewservice.com.apple.SafariViewService was interrupted, but the message was sent over an additional proxy and therefore this proxy has become invalid.}'Andrew Lombard

9 Answers

17
votes

Why do I see console messages like 'canOpenURL: failed for URL: "fb...://' or ?

This is an Xcode warning indicating the the canOpenURL: call returned false. As long as you have configured the LSApplicationQueriesSchemes entry in your plist as described above, you can ignore this warning.

9
votes

This is not a problem. The FB SDK is trying to open the native facebook app which has the fbauth2:// url type. In Simulator its not available, so its just putting a log that it could not open the native Facebook app. You can configure the Facebook acct in Simulator and then tell the FB Login button to use the native Facebook account instead of opening the web view. But Facebook contends that millions of people use Facebook in browser and so in iOS 9 they have used the new SFSafariViewController as the default behaviour for facebook logins even on devices. You can try to use the native Facebook and see if it works.

Check this link for the discussion.

https://www.facebook.com/login.php?next=https%3A%2F%2Fdevelopers.facebook.com%2Fbugs%2F786729821439894%2F%3Fsearch_id

4
votes

After you have updated your App's .plist file with the LSApplicationQueriesSchemes array, which you seem to have already done:

Next, verify that your Facebook SDK is version 4.6.0. Follow the Facebook directions if it's not.

Lastly, which is probably where the problem arises, is to Reset your Simulator's content and settings

To Reset your Simulator:

  1. Choose Simulator
  2. Select Reset Content & Settings
  3. and the Reset option

Apple's Simulator, even the IDE, will have bugs and closing and reopening, along with reseting the simulator, are always something to consider early on in your search for a solution.

Hope this helps!

3
votes

I downgraded my Facebook SDK from version 4.7 to 4.5.1 and worked fine on both Simulator and iphone device(without Facebook app installed).

1
votes

According to Facebook:

iOS SDK supports SafariViewController which lets us switch show web-rendered dialogs instead of doing an app-switch. This beta SDK will automatically determine the best app switch experience for people based on their device. For example, defaulting the person's experience through SafariViewController instead of Safari for Facebook Login....

Facebook reference link: https://developers.facebook.com/bugs/786729821439894/?search_id

Stack ref link: https://stackoverflow.com/a/32593070/2905967

0
votes

By following these steps, you may be able to avoid this error:

1) go to -> Supporting File

2) info.plist

3) Right click on info.plist -> Open As -> Select Source Code

* Add code below inside <dict>...</dict> *

<key>LSApplicationQueriesSchemes</key>
<array>
  <string>fbapi</string>
  <string>fb-messenger-api</string>
  <string>fbauth2</string>
  <string>fbshareextension</string>
</array>
0
votes

1] Authentication in Developer.facebook and generate Facebook Id like :=>460481580805052

2] Set Bitcode : No From Build Settings

3] Set up Plist File

<key>CFBundleURLTypes</key>
<array>
    <dict>
        <key>CFBundleTypeRole</key>
        <string>Editor</string>
        <key>CFBundleURLSchemes</key>
        <array>
            <string>fb460481580805052</string>
        </array>
    </dict>
</array>

<key>FacebookAppID</key>
<string>460481580805052</string>

<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSAppTransportSecurity</key>
<dict>
    <key>NSExceptionDomains</key>
    <dict>
        <key>akamaihd.net</key>
        <dict>
            <key>NSIncludesSubdomains</key>
            <true/>
            <key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
            <false/>
        </dict>
        <key>facebook.com</key>
        <dict>
            <key>NSIncludesSubdomains</key>
            <true/>
            <key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
            <false/>
        </dict>
        <key>fbcdn.net</key>
        <dict>
            <key>NSIncludesSubdomains</key>
            <true/>
            <key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
            <false/>
        </dict>
    </dict>
</dict>

<key>LSApplicationQueriesSchemes</key>
<array>
    <string>fbapi</string>
    <string>fbapi20130214</string>
    <string>fbapi20130410</string>
    <string>fbapi20130702</string>
    <string>fbapi20131010</string>
    <string>fbapi20131219</string>
    <string>fbapi20140410</string>
    <string>fbapi20140116</string>
    <string>fbapi20150313</string>
    <string>fbapi20150629</string>
    <string>fbauth</string>
    <string>fbauth2 </string>
    <string>fb-messenger-api20140430</string>
    <string>fb-messenger-platform-20150128</string>
    <string>fb-messenger-platform-20150218</string>
    <string>fb-messenger-platform-20150305</string>
</array>

4] Download 4 Sdk Framework like

=>Bolts.framework
=>FBSDKCoreKit.framework
=>FBSDKLoginKit.framework
=>FBSDKShareKit.framework
0
votes

please use LSApplicationQueriesSchemes or addd into plist your app id .

0
votes

For iOS 9 or above, add this method in your AppDelegate file:

https://stackoverflow.com/a/43515243/535013