简体   繁体   中英

Swift Facebook Auth with firebase canOpenURL: failed for URL: “fbauth2:/” - error: “The operation couldn’t be completed. (OSStatus error -10814.)”

i try to implement facebook auth with firebase at my swift app. Unfortunately i receive this error

canOpenURL: failed for URL: "fbauth2:/" - error: "The operation couldn't be completed. (OSStatus error -10814.)"

It doesnt matter if i try it with a simulator or a physical phone.

Here is my App Delegate code:

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)
}

and here is my ViewController code:

    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")
}

I was recently face the same issue in one of my project in which I have updated Swift version to 4.2 from 4.0

This issue is from Facebook 4.39.0 Pod frameworks.

FBSDKCoreKit and FBSDKLoginKit for 4.39.0 version is not working, so whenever you update your code to Swift 4.2 then kindly mention your code with specified version.

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

Thanks.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM