I use the function below to login to Facebook, but I always need to double-click the "Login" button to open the Facebook login page.
I already tested on the simulator and device. The first time I press the login button, the application goes to the loginManager.logIn (...) function, but never gets into the completion handler until the second click.
Does anyone have this problem and solution? I am using xCode 8 and Swift 3
private func loginWithFB(){
let loginManager = LoginManager()
loginManager.logIn([ .publicProfile, .userFriends, .email ], viewController: self) { loginResult in
switch loginResult {
case .failed(let error):
print(error)
case .cancelled:
print("User cancelled login.")
case .success(let grantedPermissions, let declinedPermissions, let accessToken):
}
}
}
source
share