How do you get FacebookSDK for iOS
-
I need to get the Facebook user data. I'm successful in receiving data such as user name, id, photography, but when I try to ask for, for example, family status, I'm receiving an empty vocabulary.
I've tried to make different requests, but I get that kind of result everywhere. How can I fix this? My example of the code:
static func getUserRelationship() { if (FBSDKAccessToken.currentAccessToken() != nil) { guard let currentUser = getCurrentFacebookUser() else { return } FBSDKGraphRequest(graphPath: "/\(currentUser.id)/family", parameters: nil, HTTPMethod: "GET").startWithCompletionHandler({ (requestConnection, result, error) in if error == nil { let dictionary = result as! [String : AnyObject] let array = dictionary["data"] print("facebook", result, dictionary, array?.count) } else { print(error.localizedDescription) } }) } else { getDataLogin({ getUserBirthday() }, fails: { (error) in
}) } }
I'll get the result.
facebook {
data = (
);
}
-
I didn't make a request. That's the right call.
let fbLoginManager : FBSDKLoginManager = FBSDKLoginManager() fbLoginManager.loginBehavior = FBSDKLoginBehavior.Web fbLoginManager.logInWithReadPermissions(["public_profile","email"], fromViewController: self) { (result, error) -> Void in if error != nil { print(error.localizedDescription) self.dismissViewControllerAnimated(true, completion: nil) } else if result.isCancelled { print("Cancelled") self.dismissViewControllerAnimated(true, completion: nil) } else {
}
}
And to get information, we'll call the next code.
FBSDKGraphRequest(graphPath: "me", parameters: ["fields": "id, name, first_name, relationship_status"]).startWithCompletionHandler({ (connection, result, error) -> Void in
if (error == nil){
let fbDetails = result as! NSDictionary
print(fbDetails)
}
})