xcode Facebook 登录问题 -canOpenURL:URL 失败:“fbauth2:///” - 错误:“(空)”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/32982855/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 08:00:27  来源:igfitidea点击:

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

xcodefacebookswiftparse-platformios9

提问by Alexandru Adam

I have looked at every single thread on here, I have the latest Parse SDK(1.8.5), I have the latest Facebook SDK(4.6). I'm using Xcode Version 7.0.1 with iOS9 and swift 2.0. I have read the Facebook API docs page over and over to make sure I am not missing anything as well as the parse API docs. Here is my view controller

我已经查看了这里的每个线程,我有最新的 Parse SDK(1.8.5),我有最新的 Facebook SDK(4.6)。我在 iOS9 和 swift 2.0 上使用 Xcode 7.0.1 版。我一遍又一遍地阅读 Facebook API 文档页面,以确保我没有遗漏任何内容以及解析 API 文档。这是我的视图控制器

import ParseFacebookUtilsV4
import Parse
import UIKit


class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()

        let permissions = ["public_profile"]
        PFFacebookUtils.logInInBackgroundWithReadPermissions(permissions) {
            (user: PFUser?, error: NSError?) -> Void in
            if let user = user {
                if user.isNew {
                    print("User signed up and logged in through Facebook!")
                } else {
                    print("User logged in through Facebook!")
                }
            } else {
                print("Uh oh. The user cancelled the Facebook login.")
            }
        }


    }

Here is the AppDelegate:

这是 AppDelegate:

import UIKit
import CoreData
import Parse
import Bolts
import FBSDKCoreKit
import ParseFacebookUtilsV4

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?


    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool
    {

        Parse.enableLocalDatastore()
        // Initialize Parse.
        Parse.setApplicationId("removed",
            clientKey: "removed")

        PFFacebookUtils.initializeFacebookWithApplicationLaunchOptions(launchOptions)


        return true
    }

    func application(application: UIApplication,
        openURL url: NSURL,
        sourceApplication: String?,
        annotation: AnyObject) -> Bool {
            return FBSDKApplicationDelegate.sharedInstance().application(application,
                openURL: url,
                sourceApplication: sourceApplication,
                annotation: annotation)
    }

Here is the info.plist:

这是 info.plist:

    <plist version="1.0">
<dict>
    <key>LSApplicationQueriesSchemes</key>
    <array>
        <string>fbapi</string>
        <string>fb-messenger-api</string>
        <string>fbauth2</string>
        <string>fbshareextension</string>
    </array>
    <key>NSAppTransportSecurity</key>
    <dict>
        <key>NSExceptionDomains</key>
        <dict>
            <key>facebook.com</key>
            <dict>
                <key>NSIncludesSubdomains</key>
                <true/>
                <key>NSExceptionRequiresForwardSecrecy</key>
                <false/>
            </dict>
            <key>fbcdn.net</key>
            <dict>
                <key>NSIncludesSubdomains</key>
                <true/>
                <key>NSExceptionRequiresForwardSecrecy</key>
                <false/>
            </dict>
            <key>akamaihd.net</key>
            <dict>
                <key>NSIncludesSubdomains</key>
                <true/>
                <key>NSExceptionRequiresForwardSecrecy</key>
                <false/>
            </dict>
        </dict>
    </dict>
    <key>CFBundleURLTypes</key>
    <array>
        <dict>
            <key>CFBundleURLSchemes</key>
            <array>
                <string>removed</string>
            </array>
        </dict>
    </array>
    <key>FacebookAppID</key>
    <string>removed</string>
    <key>FacebookDisplayName</key>
    <string>removed</string>
    <key>CFBundleDevelopmentRegion</key>
    <string>en</string>
    <key>CFBundleExecutable</key>
    <string>$(EXECUTABLE_NAME)</string>
    <key>CFBundleIdentifier</key>
    <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
    <key>CFBundleInfoDictionaryVersion</key>
    <string>6.0</string>
    <key>CFBundleName</key>
    <string>$(PRODUCT_NAME)</string>
    <key>CFBundlePackageType</key>
    <string>APPL</string>
    <key>CFBundleShortVersionString</key>
    <string>1.0</string>
    <key>CFBundleSignature</key>
    <string>????</string>
    <key>CFBundleVersion</key>
    <string>1</string>
    <key>LSRequiresIPhoneOS</key>
    <true/>
    <key>UILaunchStoryboardName</key>
    <string>LaunchScreen</string>
    <key>UIMainStoryboardFile</key>
    <string>Main</string>
    <key>UIRequiredDeviceCapabilities</key>
    <array>
        <string>armv7</string>
    </array>
    <key>UISupportedInterfaceOrientations</key>
    <array>
        <string>UIInterfaceOrientationPortrait</string>
        <string>UIInterfaceOrientationLandscapeLeft</string>
        <string>UIInterfaceOrientationLandscapeRight</string>
    </array>
</dict>
</plist>

No compiler issues but when I run it I get the

没有编译器问题,但是当我运行它时,我得到了

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

and when the simulator starts up just a blank screen, it does not route the Facebook login on the simulator.

当模拟器启动时只是一个空白屏幕,它不会在模拟器上路由 Facebook 登录。

Can anyone please help!

任何人都可以请帮忙!

回答by Azellius

This is an error introduced by Xcode 7 and iOS9. According to Facebook's Doc: https://developers.facebook.com/docs/ios/ios9

这是 Xcode 7 和 iOS9 引入的错误。根据 Facebook 的文档:https: //developers.facebook.com/docs/ios/ios9

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

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

这是一个 Xcode 警告,指示 canOpenURL: 调用返回 false。只要你按照上面的描述在你的 plist 中配置了 LSApplicationQueriesSchemes 条目,你就可以忽略这个警告

As long as FB login is working, and this is your only error message, you can ignore it. We get it on our production app too, hopefully Facebook will fix it in their next SDK update.

只要 FB 登录有效,并且这是您唯一的错误消息,您就可以忽略它。我们也在我们的生产应用程序中得到它,希望 Facebook 将在他们的下一次 SDK 更新中修复它。

回答by Gurjot Kalsi

you can see this link: http://myxcode.net/2015/10/28/plist-requriments-for-facebook-integration-ios-9/

你可以看到这个链接:http: //myxcode.net/2015/10/28/plist-requriments-for-facebook-integration-ios-9/

its just another addiction to array:

它只是对数组的另一种瘾:

     <key>LSApplicationQueriesSchemes</key>
 <array>
   <string>fb</string>
 </array>