iOS 9 Facebook login simulator -canOpenURL: failed for URL: "fbauth2:///" - error: "(null)"

iOS 9 Facebook login simulator -canOpenURL: failed for URL: "fbauth2:///" - error: "(null)"

我已经更新到 Xcode 7 和最新的 iOS SDK。我已经在我的应用程序的 plist 中添加了适当的条目:

我的应用程序的 Facebook 登录在设备上运行良好。但是,在 iOS 9 模拟器上,我得到:

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

登录失败。我看过 facebook login issue - canOpenURL: failed for URL: "fbauth2:///" - error: "(null)" but I have FBSDKCoreKit framework. I've also seen 但它的答案并没有解决我的问题。

即使我在 https://developers.facebook.com/docs/ios/ios9 完成了检查清单,为什么我在模拟器上而不是在设备上收到此错误?

根据 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 参考资料 link:https://developers.facebook.com/bugs/786729821439894/?search_id

堆栈参考 link:

通过执行以下步骤,您或许可以避免此错误:

1) 转到 -> 支持文件

2) info.plist

3) 右键单击​​ info.plist -> 打开为 -> Select 源代码

* 在下面添加代码 <dict>...</dict> *

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

LSApplicationQueriesSchemes 数组更新应用的 .plist 文件后,您似乎已经完成了:

下一步,确认您的 Facebook SDK 是版本 4.6.0。如果不是,请关注Facebook directions

最后,这可能是问题出现的地方,是重置你的模拟器的内容和设置

重置模拟器:

  1. 选择模拟器
  2. Select 重置内容和设置
  3. 重置选项

Apple 的模拟器,即使是 IDE,也会有错误,关闭和重新打开,以及重置模拟器,总是在您寻找解决方案的早期考虑的事情。

希望对您有所帮助!

我将我的 Facebook SDK 从版本 4.7 降级到 4.5.1,并且在模拟器和 iphone 设备(没有安装 Facebook 应用程序)上都运行良好。

为什么我会看到类似 'canOpenURL: failed for URL: "fb...://' 或 ?

的控制台消息

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.

这不是问题。 FB SDK 正在尝试打开具有 fbauth2:// url 类型的本机 facebook 应用程序。在模拟器中它不可用,所以它只是放置一个日志,它无法打开本机 Facebook 应用程序。您可以在模拟器中配置 Facebook 帐户,然后告诉 FB 登录按钮使用本机 Facebook 帐户而不是打开 Web 视图。但 Facebook 争辩说,数以百万计的人在浏览器中使用 Facebook,因此在 iOS 9 他们甚至在设备上使用新的 SFSafariViewController 作为 facebook 登录的默认行为。你可以试试用原生的Facebook看看能不能用

检查此 link 以进行讨论。

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

1] 在 Developer.facebook 中进行身份验证并生成 Facebook Id,例如:=>460481580805052

2] 设置位码:否来自构建设置

3] 设置 Plist 文件

<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] 下载4个Sdk框架like

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

请使用 LSApplicationQueriesSchemes 或将您的应用程序 ID 添加到 plist 中。

对于 iOS 9 或更高版本,在您的 AppDelegate 文件中添加此方法: