TL;TR: How do I get the email and name of a user that is logged in on my app using the facebook SDK 4.4
So far I have managed to get login working, now I can get the
you can use this code to get email ,name and profile picture of user
@IBAction func fbsignup(_ sender: Any) {
let fbloginManger: FBSDKLoginManager = FBSDKLoginManager()
fbloginManger.logIn(withReadPermissions: ["email"], from:self) {(result, error) -> Void in
if(error == nil){
let fbLoginResult: FBSDKLoginManagerLoginResult = result!
if( result?.isCancelled)!{
return }
if(fbLoginResult .grantedPermissions.contains("email")){
self.getFbId()
}
} }
}
func getFbId(){
if(FBSDKAccessToken.current() != nil){
FBSDKGraphRequest(graphPath: "me", parameters: ["fields": "id,name , first_name, last_name , email,picture.type(large)"]).start(completionHandler: { (connection, result, error) in
guard let Info = result as? [String: Any] else { return }
if let imageURL = ((Info["picture"] as? [String: Any])?["data"] as? [String: Any])?["url"] as? String {
//Download image from imageURL
}
if(error == nil){
print("result")
}
})
}
}