facebook login issue - canOpenURL: failed for URL: “fbauth2:///” - error: “(null)”

前端 未结 9 823
被撕碎了的回忆
被撕碎了的回忆 2020-12-08 18:13

When I click on login with Facebook button, it is opening safari browser and getting closed immediately. Noticed error on the console.

App delegate method:



        
9条回答
  •  长情又很酷
    2020-12-08 18:38

    I figured out my issue. It was just the syntax in loginButtonClicked function. The error message was leading me down the wrong path. Here is the working code.

    @objc func loginButtonClicked() {
        self.login = FBSDKLoginManager()
    
        self.login.logIn(withReadPermissions: ["public_profile"], from: self, handler: {(result, error) -> Void in
            if error != nil {
                print("Process error")
            }
            else if (result?.isCancelled)! {
                print("Cancelled")
            }
            else {
                print("Logged in")
                DispatchQueue.main.async(execute: {
                    let viewController:UIViewController = self.storyboard?.instantiateViewController(withIdentifier: "UITabBarController") as! UITabBarController
                    self.present(viewController, animated: true, completion: nil)
                })
            }
    
            })
    }
    

提交回复
热议问题