Facebook登录无法始终正常工作。
它将始终显示登录页面,但是成功登录后,有时将无法获取访问令牌。它有时会工作,而有时却没有。这是我获取令牌的地方。
func loginButton(_ loginButton: FBSDKLoginButton!, didCompleteWith result: FBSDKLoginManagerLoginResult!, error: Error!) {
print("Login button did complete with result")
let accessToken = FBSDKAccessToken.current()
guard let accessTokenString = accessToken?.tokenString else {
ProgressHUD.showError("There was an error")
return }
let credentials = FacebookAuthProvider.credential(withAccessToken: accessTokenString)
print("Granted Permissions: \(result.grantedPermissions)")
if error != nil {
print("There was an error")
ProgressHUD.showError(error.localizedDescription)
return
} else if result.isCancelled {
ProgressHUD.dismiss()
} else {
ProgressHUD.show("Loading")