i have integrated Facebook sdk in Xcode 6 (with swift). During the login i request the public_profile permission:
FBSession.openActiveSessionWithReadPermissions(
Swift 4 approach :-
private func fetchUserData() {
let graphRequest = FBSDKGraphRequest(graphPath: "me", parameters: ["fields":"id, email, name, picture.width(480).height(480)"])
graphRequest?.start(completionHandler: { (connection, result, error) in
if error != nil {
print("Error",error!.localizedDescription)
}
else{
print(result!)
let field = result! as? [String:Any]
self.userNameLabel.text = field!["name"] as? String
if let imageURL = ((field!["picture"] as? [String: Any])?["data"] as? [String: Any])?["url"] as? String {
print(imageURL)
let url = URL(string: imageURL)
let data = NSData(contentsOf: url!)
let image = UIImage(data: data! as Data)
self.profileImageView.image = image
}
}
})
}