使用Firebase canOpenURL的Swift Facebook Auth:URL失败:“ fbauth2:/”-错误:“该操作无法完成。(OSStatus错误-10814。)

时间:2019-03-04 09:45:04

标签: ios swift

我尝试在我的swift应用中使用firebase实现facebook auth。不幸的是,我收到此错误

  

canOpenURL:URL失败:“ fbauth2:/”-错误:“操作无法完成。(OSStatus错误-10814。)”

我是用模拟器还是实体电话尝试都没关系。

这是我的应用程序委托代码:

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
    // Override point for customization after application launch.
    FirebaseApp.configure()
    FBSDKApplicationDelegate.sharedInstance()?.application(application, didFinishLaunchingWithOptions: launchOptions)

    return true
}
func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool {
    return FBSDKApplicationDelegate.sharedInstance().application(application, open: url, sourceApplication: sourceApplication, annotation: annotation)
}

这是我的ViewController代码:

    override func viewDidLoad() {
    super.viewDidLoad()

    let loginButton = FBSDKLoginButton()
    view.addSubview(loginButton)
    loginButton.frame = CGRect(x: 16, y: 50, width: view.frame.width-30, height: 50)

    // Do any additional setup after loading the view.s


}


  func loginButton(_ loginButton: FBSDKLoginButton!, didCompleteWith result: FBSDKLoginManagerLoginResult!, error: Error!) {
    if let error = error {
        print(error.localizedDescription)
        return
    }else{
        print("worked")
    }
}

 func loginButtonDidLogOut(_ loginButton: FBSDKLoginButton!) {
    print("logged out")
}

1 个答案:

答案 0 :(得分:1)

我最近在我的一个项目中遇到了同样的问题,我将Swift版本从4.0更新到了4.2

此问题来自Facebook 4.39.0 Pod框架。

用于4.39.0版本的FBSDKCoreKit和FBSDKLoginKit不起作用,因此,每当您将代码更新为Swift 4.2时,都请使用指定的版本提及代码。

pod 'FBSDKCoreKit', '~> 4.38.1'
pod 'FBSDKLoginKit', '~> 4.38.1'
pod 'FBSDKShareKit', '~> 4.38.1'

谢谢。