iOS Facebook Sdk 4.0 Login Error Code 304

(com.facebook.sdk.login error 304.) Error with FBSDK 4.2

It seems I was doing

[FBSDKAccessToken refreshCurrentAccessToken:^(FBSDKGraphRequestConnection *connection, id result, NSError *error){}

in a background thread during login operation. I removed that and It worked perfectly fine.

Login failed with facebook. It works with one facebook account, yet it throws an error when trying with another account

Sometimes fbloginresult.grantedPermissions will be nil.i am using below code

  self.fbLoginManager = FBSDKLoginManager.init()
fbLoginManager.loginBehavior = FBSDKLoginBehavior.web
self.fbLoginManager.logIn(withReadPermissions: ["email"], from: self) { (result, error) -> Void in
if (error == nil) {
let fbloginresult : FBSDKLoginManagerLoginResult = result!
if fbloginresult.grantedPermissions != nil && fbloginresult.grantedPermissions.contains("email") {
if((FBSDKAccessToken.current()) != nil){
FBSDKGraphRequest(graphPath: "me", parameters: ["fields":"id, first_name, last_name, email, gender, birthday, location"]).start(completionHandler: { (connection, result, error) -> Void in
if error != nil {
print(error?.localizedDescription ?? "error in facebook login...!")
return
}
if let dict = result as? NSDictionary {
print("facebook login result --->\n\(dict)")
guard let id = dict["id"] else {
print("Ooops... id = nil")
return
}
let firstName: String = dict["first_name"] as? String ?? ""
let lastName : String = dict["last_name"] as? String ?? ""
let email : String = dict["email"] as? String ?? ""

print(firstName,lastName,email)

// here you can process your next step
self.fbLoginManager.logOut()
}
})
}
} else {
print("facebook ---> login canceled")
}
} else {
print(error?.localizedDescription ?? "facebook login has error")
}
}


Related Topics



Leave a reply



Submit