iOS Facebook SDK: FBSDKGraphRequest doesn't return email (Swift)facebook graph api not returning all dataAny Example showing how to login using Facebook SDK 4.0 in Android either by using own button or Facebook Button?Facebook login fails (always isCancelled) after upgrading to SDK 4.1Add Facebook “name” to PFUser [“fullname”] in swiftFacebook Android SDK — no 'email' in meRequestHow to get user email from facebook sdk 4 whith swiftFacebook iOS SDK / FBSDKLoginButton ignoring read permissionsFacebook is returning anything when recompiling with iOS9FBSDK findByGraphPath (me) doesn't return an email, even with permissions and explicit fieldsProgrammatically logout of Facebook app in Swift

Simplify, equivalent for (p ∨ ¬q) ∧ (¬p ∨ ¬q)

How can caller ID be faked?

How can I maintain game balance while allowing my player to craft genuinely useful items?

I have found ports on my Samsung smart tv running a display service. What can I do with it?

Leaving job close to major deadlines

Query nodes and attributes of parent ways

Using roof rails to set up hammock

What is the context for Napoleon's quote "[the Austrians] did not know the value of five minutes"?

writing a function between sets vertically

Are there examples of rowers who also fought?

King or Queen-Which piece is which?

Operator currying: how to convert f[a,b][c,d] to a+c,b+d?

I'm yearning in grey

Credit card validation in C

Would a 7805 5v regulator drain a 9v battery?

If the mass of the Earth is decreasing by sending debris in space, does its angular momentum also decrease?

Time at 1G acceleration to travel 100 000 light years

Is using Legacy mode is a bad thing to do?

Do battery electrons only move if there is a positive terminal at the end of the wire?

Justifying Affordable Bespoke Spaceships

What is "dot" sign in •NO?

When is the phrase "j'ai bon" used?

I wish, I yearn, for an answer to this riddle

How do I correctly reduce geometry on part of a mesh?



iOS Facebook SDK: FBSDKGraphRequest doesn't return email (Swift)


facebook graph api not returning all dataAny Example showing how to login using Facebook SDK 4.0 in Android either by using own button or Facebook Button?Facebook login fails (always isCancelled) after upgrading to SDK 4.1Add Facebook “name” to PFUser [“fullname”] in swiftFacebook Android SDK — no 'email' in meRequestHow to get user email from facebook sdk 4 whith swiftFacebook iOS SDK / FBSDKLoginButton ignoring read permissionsFacebook is returning anything when recompiling with iOS9FBSDK findByGraphPath (me) doesn't return an email, even with permissions and explicit fieldsProgrammatically logout of Facebook app in Swift






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








2















I've seen similar questions on here but none seem to resolve my issue.



I'm currently creating an iOS app that uses the Facebook SDK to login and return user information.



I've successfully logged into facebook and receive the requested information. However, the request is not returning email despite allowing read permission for email.



 /********************
Place Facebook login button
*********************/
let loginButton = FBSDKLoginButton()
view.addSubview(loginButton)
loginButton.delegate = self
loginButton.readPermissions = ["email", "public_profile"]
//add button constraints
loginButton.center = view.center



}

/**
* Functions called when user handed back from facebook login
**/
func loginButtonDidLogOut(_ loginButton: FBSDKLoginButton!)
print("Did log out of facebook")

/**
* Functions called when user handed back from facebook login
**/
func loginButton(_ loginButton: FBSDKLoginButton!, didCompleteWith result: FBSDKLoginManagerLoginResult!, error: Error!)
if error != nil
print(error)
else

print("Successfully logged in with facebook")
FBSDKGraphRequest(graphPath: "/me", parameters: ["fields": "id, name, email"]).start
(connection, result, err) in
if err != nil
print("Failed to start graph request: ", err)
return

print(result)












share|improve this question






















  • Email is only returned if the user has confirmed and verified it already. Plus there are some rare situations in which privacy settings make it not return the email, even if the user granted the permission. If your app absolutely needs an email, then you should implement an additional step to let users input it manually (of course verification becomes your responsibility too then) ... not every user even has an email on file with Facebook, for example if they registered using only their mobile.

    – CBroe
    Jun 15 '17 at 7:56

















2















I've seen similar questions on here but none seem to resolve my issue.



I'm currently creating an iOS app that uses the Facebook SDK to login and return user information.



I've successfully logged into facebook and receive the requested information. However, the request is not returning email despite allowing read permission for email.



 /********************
Place Facebook login button
*********************/
let loginButton = FBSDKLoginButton()
view.addSubview(loginButton)
loginButton.delegate = self
loginButton.readPermissions = ["email", "public_profile"]
//add button constraints
loginButton.center = view.center



}

/**
* Functions called when user handed back from facebook login
**/
func loginButtonDidLogOut(_ loginButton: FBSDKLoginButton!)
print("Did log out of facebook")

/**
* Functions called when user handed back from facebook login
**/
func loginButton(_ loginButton: FBSDKLoginButton!, didCompleteWith result: FBSDKLoginManagerLoginResult!, error: Error!)
if error != nil
print(error)
else

print("Successfully logged in with facebook")
FBSDKGraphRequest(graphPath: "/me", parameters: ["fields": "id, name, email"]).start
(connection, result, err) in
if err != nil
print("Failed to start graph request: ", err)
return

print(result)












share|improve this question






















  • Email is only returned if the user has confirmed and verified it already. Plus there are some rare situations in which privacy settings make it not return the email, even if the user granted the permission. If your app absolutely needs an email, then you should implement an additional step to let users input it manually (of course verification becomes your responsibility too then) ... not every user even has an email on file with Facebook, for example if they registered using only their mobile.

    – CBroe
    Jun 15 '17 at 7:56













2












2








2








I've seen similar questions on here but none seem to resolve my issue.



I'm currently creating an iOS app that uses the Facebook SDK to login and return user information.



I've successfully logged into facebook and receive the requested information. However, the request is not returning email despite allowing read permission for email.



 /********************
Place Facebook login button
*********************/
let loginButton = FBSDKLoginButton()
view.addSubview(loginButton)
loginButton.delegate = self
loginButton.readPermissions = ["email", "public_profile"]
//add button constraints
loginButton.center = view.center



}

/**
* Functions called when user handed back from facebook login
**/
func loginButtonDidLogOut(_ loginButton: FBSDKLoginButton!)
print("Did log out of facebook")

/**
* Functions called when user handed back from facebook login
**/
func loginButton(_ loginButton: FBSDKLoginButton!, didCompleteWith result: FBSDKLoginManagerLoginResult!, error: Error!)
if error != nil
print(error)
else

print("Successfully logged in with facebook")
FBSDKGraphRequest(graphPath: "/me", parameters: ["fields": "id, name, email"]).start
(connection, result, err) in
if err != nil
print("Failed to start graph request: ", err)
return

print(result)












share|improve this question














I've seen similar questions on here but none seem to resolve my issue.



I'm currently creating an iOS app that uses the Facebook SDK to login and return user information.



I've successfully logged into facebook and receive the requested information. However, the request is not returning email despite allowing read permission for email.



 /********************
Place Facebook login button
*********************/
let loginButton = FBSDKLoginButton()
view.addSubview(loginButton)
loginButton.delegate = self
loginButton.readPermissions = ["email", "public_profile"]
//add button constraints
loginButton.center = view.center



}

/**
* Functions called when user handed back from facebook login
**/
func loginButtonDidLogOut(_ loginButton: FBSDKLoginButton!)
print("Did log out of facebook")

/**
* Functions called when user handed back from facebook login
**/
func loginButton(_ loginButton: FBSDKLoginButton!, didCompleteWith result: FBSDKLoginManagerLoginResult!, error: Error!)
if error != nil
print(error)
else

print("Successfully logged in with facebook")
FBSDKGraphRequest(graphPath: "/me", parameters: ["fields": "id, name, email"]).start
(connection, result, err) in
if err != nil
print("Failed to start graph request: ", err)
return

print(result)









ios swift facebook facebook-sdk-4.0






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jun 14 '17 at 17:44









Calum.BCalum.B

319




319












  • Email is only returned if the user has confirmed and verified it already. Plus there are some rare situations in which privacy settings make it not return the email, even if the user granted the permission. If your app absolutely needs an email, then you should implement an additional step to let users input it manually (of course verification becomes your responsibility too then) ... not every user even has an email on file with Facebook, for example if they registered using only their mobile.

    – CBroe
    Jun 15 '17 at 7:56

















  • Email is only returned if the user has confirmed and verified it already. Plus there are some rare situations in which privacy settings make it not return the email, even if the user granted the permission. If your app absolutely needs an email, then you should implement an additional step to let users input it manually (of course verification becomes your responsibility too then) ... not every user even has an email on file with Facebook, for example if they registered using only their mobile.

    – CBroe
    Jun 15 '17 at 7:56
















Email is only returned if the user has confirmed and verified it already. Plus there are some rare situations in which privacy settings make it not return the email, even if the user granted the permission. If your app absolutely needs an email, then you should implement an additional step to let users input it manually (of course verification becomes your responsibility too then) ... not every user even has an email on file with Facebook, for example if they registered using only their mobile.

– CBroe
Jun 15 '17 at 7:56





Email is only returned if the user has confirmed and verified it already. Plus there are some rare situations in which privacy settings make it not return the email, even if the user granted the permission. If your app absolutely needs an email, then you should implement an additional step to let users input it manually (of course verification becomes your responsibility too then) ... not every user even has an email on file with Facebook, for example if they registered using only their mobile.

– CBroe
Jun 15 '17 at 7:56












3 Answers
3






active

oldest

votes


















0














You can't fetch the users email from an FBSDKGraphRequest according to Facebook Graph API tool. Facebook only returns the token used to login. If you used Facebook login with Firebase you could fetch the email with CurrentUser.currentEmail Method.



 let login = FBSDKLoginManager()

login.logIn(withReadPermissions: ["email","user_posts","public_profile"], from: self, handler:
(result: FBSDKLoginManagerLoginResult?, error: Error?) in
if error != nil
print("Process error")
return

else if (result?.isCancelled)!
print("Cancelled")

else
//Success!
let credential = FIRFacebookAuthProvider.credential(withAccessToken: FBSDKAccessToken.current().tokenString)
self.firebaseLogin(credential)

)





share|improve this answer























  • Okay thanks. I see that Firebase does not store any email address when user signs up. I'll find a way around this. Thanks again

    – Calum.B
    Jun 14 '17 at 19:30











  • Right, in Swift 2 and the older Firebase + Facebook SDKs the method above was allowed but now you can just write 'FIRAuth.auth()?.currentUser?.email'

    – Fallah
    Jun 14 '17 at 23:42



















0














 import FBSDKCoreKit
import FBSDKLoginKit
import FBSDKShareKit


@IBAction func btnFbPressed(_ sender: Any)

let loginManager = FBSDKLoginManager()

loginManager.logIn(withReadPermissions: ["public_profile", "email"], from: self) (loginResult, error) in

if error != nil
print(error!)


else

if (loginResult?.grantedPermissions.contains("email"))!
self.getFBUserData()











func getFBUserData()
if((FBSDKAccessToken.current()) != nil)

UserDefaults.standard.set(FBSDKAccessToken.current().tokenString, forKey: "fbToken")

FBSDKGraphRequest(graphPath: "me", parameters: ["fields": "id, name, first_name, last_name, picture.type(large), email"]).start(completionHandler: (connection, result, error) -> Void in
if (error == nil)

print(result as Any)

let dictionary = result as! NSDictionary
print(dictionary)

let hud = MBProgressHUD.showAdded(to: self.view, animated: true)
hud.tintColor = .black
hud.mode = .indeterminate
hud.label.text = "Loading"
hud.animationType = .fade
hud.show(animated: true)

let postString = String(format: "login_type=facebook&email=%@&id=%@&device=0", arguments: [dictionary.value(forKey: "email") as! String, dictionary.value(forKey: "id") as! String])

)







share|improve this answer






























    0














    Well i pondered on this for a long time and came upon this link which suggested that if you don't have a confirmed email address I won't get it back in the login section of my code.



    let request = GraphRequest(graphPath: "me", parameters: ["fields": "id, email, name, first_name, last_name, picture.type(large)"], accessToken: AccessToken.current, httpMethod: .GET, apiVersion: "2.12")
    request.start (response, result) in
    switch result
    case .success(let value):
    print(value.dictionaryValue!)
    self.responseJSON = JSON(value.dictionaryValue!)
    let fullName = self.responseJSON["first_name"].stringValue
    let firstName = self.responseJSON["first_name"].stringValue
    let lastName = self.responseJSON["last_name"].stringValue
    let email = self.responseJSON["email"].stringValue
    let idFb = self.responseJSON["id"].stringValue
    let picture = self.responseJSON["picture"]["data"]["url"].stringValue

    print("user id: (idFb), firstName: (firstName), fullname: (fullName), lastname: (lastName), picture: (picture), email: (email)")

    print("ALL FIELDS PUBLISHED")


    if let delegate = self.responseDelegate
    delegate.responseUpdated(self.responseJSON, forLogin: "FB")


    case .failed(let error):
    print(error)


    }


    Hence when I got to it and confirmed my email address it gave me the email in response. Here are some attached snapshots.



    enter image description here



    enter image description here



    enter image description here



    This is how i got to it. Later I implemented that if the email is not returned, I showed an alert alerting the user that there is no email associated with that facebook account and either they confirm their email or proceed by giving a separate email address in an TextField Alert. And thats that.






    share|improve this answer























      Your Answer






      StackExchange.ifUsing("editor", function ()
      StackExchange.using("externalEditor", function ()
      StackExchange.using("snippets", function ()
      StackExchange.snippets.init();
      );
      );
      , "code-snippets");

      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "1"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader:
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      ,
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );













      draft saved

      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f44551386%2fios-facebook-sdk-fbsdkgraphrequest-doesnt-return-email-swift%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown

























      3 Answers
      3






      active

      oldest

      votes








      3 Answers
      3






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      0














      You can't fetch the users email from an FBSDKGraphRequest according to Facebook Graph API tool. Facebook only returns the token used to login. If you used Facebook login with Firebase you could fetch the email with CurrentUser.currentEmail Method.



       let login = FBSDKLoginManager()

      login.logIn(withReadPermissions: ["email","user_posts","public_profile"], from: self, handler:
      (result: FBSDKLoginManagerLoginResult?, error: Error?) in
      if error != nil
      print("Process error")
      return

      else if (result?.isCancelled)!
      print("Cancelled")

      else
      //Success!
      let credential = FIRFacebookAuthProvider.credential(withAccessToken: FBSDKAccessToken.current().tokenString)
      self.firebaseLogin(credential)

      )





      share|improve this answer























      • Okay thanks. I see that Firebase does not store any email address when user signs up. I'll find a way around this. Thanks again

        – Calum.B
        Jun 14 '17 at 19:30











      • Right, in Swift 2 and the older Firebase + Facebook SDKs the method above was allowed but now you can just write 'FIRAuth.auth()?.currentUser?.email'

        – Fallah
        Jun 14 '17 at 23:42
















      0














      You can't fetch the users email from an FBSDKGraphRequest according to Facebook Graph API tool. Facebook only returns the token used to login. If you used Facebook login with Firebase you could fetch the email with CurrentUser.currentEmail Method.



       let login = FBSDKLoginManager()

      login.logIn(withReadPermissions: ["email","user_posts","public_profile"], from: self, handler:
      (result: FBSDKLoginManagerLoginResult?, error: Error?) in
      if error != nil
      print("Process error")
      return

      else if (result?.isCancelled)!
      print("Cancelled")

      else
      //Success!
      let credential = FIRFacebookAuthProvider.credential(withAccessToken: FBSDKAccessToken.current().tokenString)
      self.firebaseLogin(credential)

      )





      share|improve this answer























      • Okay thanks. I see that Firebase does not store any email address when user signs up. I'll find a way around this. Thanks again

        – Calum.B
        Jun 14 '17 at 19:30











      • Right, in Swift 2 and the older Firebase + Facebook SDKs the method above was allowed but now you can just write 'FIRAuth.auth()?.currentUser?.email'

        – Fallah
        Jun 14 '17 at 23:42














      0












      0








      0







      You can't fetch the users email from an FBSDKGraphRequest according to Facebook Graph API tool. Facebook only returns the token used to login. If you used Facebook login with Firebase you could fetch the email with CurrentUser.currentEmail Method.



       let login = FBSDKLoginManager()

      login.logIn(withReadPermissions: ["email","user_posts","public_profile"], from: self, handler:
      (result: FBSDKLoginManagerLoginResult?, error: Error?) in
      if error != nil
      print("Process error")
      return

      else if (result?.isCancelled)!
      print("Cancelled")

      else
      //Success!
      let credential = FIRFacebookAuthProvider.credential(withAccessToken: FBSDKAccessToken.current().tokenString)
      self.firebaseLogin(credential)

      )





      share|improve this answer













      You can't fetch the users email from an FBSDKGraphRequest according to Facebook Graph API tool. Facebook only returns the token used to login. If you used Facebook login with Firebase you could fetch the email with CurrentUser.currentEmail Method.



       let login = FBSDKLoginManager()

      login.logIn(withReadPermissions: ["email","user_posts","public_profile"], from: self, handler:
      (result: FBSDKLoginManagerLoginResult?, error: Error?) in
      if error != nil
      print("Process error")
      return

      else if (result?.isCancelled)!
      print("Cancelled")

      else
      //Success!
      let credential = FIRFacebookAuthProvider.credential(withAccessToken: FBSDKAccessToken.current().tokenString)
      self.firebaseLogin(credential)

      )






      share|improve this answer












      share|improve this answer



      share|improve this answer










      answered Jun 14 '17 at 18:02









      FallahFallah

      1337




      1337












      • Okay thanks. I see that Firebase does not store any email address when user signs up. I'll find a way around this. Thanks again

        – Calum.B
        Jun 14 '17 at 19:30











      • Right, in Swift 2 and the older Firebase + Facebook SDKs the method above was allowed but now you can just write 'FIRAuth.auth()?.currentUser?.email'

        – Fallah
        Jun 14 '17 at 23:42


















      • Okay thanks. I see that Firebase does not store any email address when user signs up. I'll find a way around this. Thanks again

        – Calum.B
        Jun 14 '17 at 19:30











      • Right, in Swift 2 and the older Firebase + Facebook SDKs the method above was allowed but now you can just write 'FIRAuth.auth()?.currentUser?.email'

        – Fallah
        Jun 14 '17 at 23:42

















      Okay thanks. I see that Firebase does not store any email address when user signs up. I'll find a way around this. Thanks again

      – Calum.B
      Jun 14 '17 at 19:30





      Okay thanks. I see that Firebase does not store any email address when user signs up. I'll find a way around this. Thanks again

      – Calum.B
      Jun 14 '17 at 19:30













      Right, in Swift 2 and the older Firebase + Facebook SDKs the method above was allowed but now you can just write 'FIRAuth.auth()?.currentUser?.email'

      – Fallah
      Jun 14 '17 at 23:42






      Right, in Swift 2 and the older Firebase + Facebook SDKs the method above was allowed but now you can just write 'FIRAuth.auth()?.currentUser?.email'

      – Fallah
      Jun 14 '17 at 23:42














      0














       import FBSDKCoreKit
      import FBSDKLoginKit
      import FBSDKShareKit


      @IBAction func btnFbPressed(_ sender: Any)

      let loginManager = FBSDKLoginManager()

      loginManager.logIn(withReadPermissions: ["public_profile", "email"], from: self) (loginResult, error) in

      if error != nil
      print(error!)


      else

      if (loginResult?.grantedPermissions.contains("email"))!
      self.getFBUserData()











      func getFBUserData()
      if((FBSDKAccessToken.current()) != nil)

      UserDefaults.standard.set(FBSDKAccessToken.current().tokenString, forKey: "fbToken")

      FBSDKGraphRequest(graphPath: "me", parameters: ["fields": "id, name, first_name, last_name, picture.type(large), email"]).start(completionHandler: (connection, result, error) -> Void in
      if (error == nil)

      print(result as Any)

      let dictionary = result as! NSDictionary
      print(dictionary)

      let hud = MBProgressHUD.showAdded(to: self.view, animated: true)
      hud.tintColor = .black
      hud.mode = .indeterminate
      hud.label.text = "Loading"
      hud.animationType = .fade
      hud.show(animated: true)

      let postString = String(format: "login_type=facebook&email=%@&id=%@&device=0", arguments: [dictionary.value(forKey: "email") as! String, dictionary.value(forKey: "id") as! String])

      )







      share|improve this answer



























        0














         import FBSDKCoreKit
        import FBSDKLoginKit
        import FBSDKShareKit


        @IBAction func btnFbPressed(_ sender: Any)

        let loginManager = FBSDKLoginManager()

        loginManager.logIn(withReadPermissions: ["public_profile", "email"], from: self) (loginResult, error) in

        if error != nil
        print(error!)


        else

        if (loginResult?.grantedPermissions.contains("email"))!
        self.getFBUserData()











        func getFBUserData()
        if((FBSDKAccessToken.current()) != nil)

        UserDefaults.standard.set(FBSDKAccessToken.current().tokenString, forKey: "fbToken")

        FBSDKGraphRequest(graphPath: "me", parameters: ["fields": "id, name, first_name, last_name, picture.type(large), email"]).start(completionHandler: (connection, result, error) -> Void in
        if (error == nil)

        print(result as Any)

        let dictionary = result as! NSDictionary
        print(dictionary)

        let hud = MBProgressHUD.showAdded(to: self.view, animated: true)
        hud.tintColor = .black
        hud.mode = .indeterminate
        hud.label.text = "Loading"
        hud.animationType = .fade
        hud.show(animated: true)

        let postString = String(format: "login_type=facebook&email=%@&id=%@&device=0", arguments: [dictionary.value(forKey: "email") as! String, dictionary.value(forKey: "id") as! String])

        )







        share|improve this answer

























          0












          0








          0







           import FBSDKCoreKit
          import FBSDKLoginKit
          import FBSDKShareKit


          @IBAction func btnFbPressed(_ sender: Any)

          let loginManager = FBSDKLoginManager()

          loginManager.logIn(withReadPermissions: ["public_profile", "email"], from: self) (loginResult, error) in

          if error != nil
          print(error!)


          else

          if (loginResult?.grantedPermissions.contains("email"))!
          self.getFBUserData()











          func getFBUserData()
          if((FBSDKAccessToken.current()) != nil)

          UserDefaults.standard.set(FBSDKAccessToken.current().tokenString, forKey: "fbToken")

          FBSDKGraphRequest(graphPath: "me", parameters: ["fields": "id, name, first_name, last_name, picture.type(large), email"]).start(completionHandler: (connection, result, error) -> Void in
          if (error == nil)

          print(result as Any)

          let dictionary = result as! NSDictionary
          print(dictionary)

          let hud = MBProgressHUD.showAdded(to: self.view, animated: true)
          hud.tintColor = .black
          hud.mode = .indeterminate
          hud.label.text = "Loading"
          hud.animationType = .fade
          hud.show(animated: true)

          let postString = String(format: "login_type=facebook&email=%@&id=%@&device=0", arguments: [dictionary.value(forKey: "email") as! String, dictionary.value(forKey: "id") as! String])

          )







          share|improve this answer













           import FBSDKCoreKit
          import FBSDKLoginKit
          import FBSDKShareKit


          @IBAction func btnFbPressed(_ sender: Any)

          let loginManager = FBSDKLoginManager()

          loginManager.logIn(withReadPermissions: ["public_profile", "email"], from: self) (loginResult, error) in

          if error != nil
          print(error!)


          else

          if (loginResult?.grantedPermissions.contains("email"))!
          self.getFBUserData()











          func getFBUserData()
          if((FBSDKAccessToken.current()) != nil)

          UserDefaults.standard.set(FBSDKAccessToken.current().tokenString, forKey: "fbToken")

          FBSDKGraphRequest(graphPath: "me", parameters: ["fields": "id, name, first_name, last_name, picture.type(large), email"]).start(completionHandler: (connection, result, error) -> Void in
          if (error == nil)

          print(result as Any)

          let dictionary = result as! NSDictionary
          print(dictionary)

          let hud = MBProgressHUD.showAdded(to: self.view, animated: true)
          hud.tintColor = .black
          hud.mode = .indeterminate
          hud.label.text = "Loading"
          hud.animationType = .fade
          hud.show(animated: true)

          let postString = String(format: "login_type=facebook&email=%@&id=%@&device=0", arguments: [dictionary.value(forKey: "email") as! String, dictionary.value(forKey: "id") as! String])

          )








          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Jun 16 '17 at 5:54









          Amul4608Amul4608

          890423




          890423





















              0














              Well i pondered on this for a long time and came upon this link which suggested that if you don't have a confirmed email address I won't get it back in the login section of my code.



              let request = GraphRequest(graphPath: "me", parameters: ["fields": "id, email, name, first_name, last_name, picture.type(large)"], accessToken: AccessToken.current, httpMethod: .GET, apiVersion: "2.12")
              request.start (response, result) in
              switch result
              case .success(let value):
              print(value.dictionaryValue!)
              self.responseJSON = JSON(value.dictionaryValue!)
              let fullName = self.responseJSON["first_name"].stringValue
              let firstName = self.responseJSON["first_name"].stringValue
              let lastName = self.responseJSON["last_name"].stringValue
              let email = self.responseJSON["email"].stringValue
              let idFb = self.responseJSON["id"].stringValue
              let picture = self.responseJSON["picture"]["data"]["url"].stringValue

              print("user id: (idFb), firstName: (firstName), fullname: (fullName), lastname: (lastName), picture: (picture), email: (email)")

              print("ALL FIELDS PUBLISHED")


              if let delegate = self.responseDelegate
              delegate.responseUpdated(self.responseJSON, forLogin: "FB")


              case .failed(let error):
              print(error)


              }


              Hence when I got to it and confirmed my email address it gave me the email in response. Here are some attached snapshots.



              enter image description here



              enter image description here



              enter image description here



              This is how i got to it. Later I implemented that if the email is not returned, I showed an alert alerting the user that there is no email associated with that facebook account and either they confirm their email or proceed by giving a separate email address in an TextField Alert. And thats that.






              share|improve this answer



























                0














                Well i pondered on this for a long time and came upon this link which suggested that if you don't have a confirmed email address I won't get it back in the login section of my code.



                let request = GraphRequest(graphPath: "me", parameters: ["fields": "id, email, name, first_name, last_name, picture.type(large)"], accessToken: AccessToken.current, httpMethod: .GET, apiVersion: "2.12")
                request.start (response, result) in
                switch result
                case .success(let value):
                print(value.dictionaryValue!)
                self.responseJSON = JSON(value.dictionaryValue!)
                let fullName = self.responseJSON["first_name"].stringValue
                let firstName = self.responseJSON["first_name"].stringValue
                let lastName = self.responseJSON["last_name"].stringValue
                let email = self.responseJSON["email"].stringValue
                let idFb = self.responseJSON["id"].stringValue
                let picture = self.responseJSON["picture"]["data"]["url"].stringValue

                print("user id: (idFb), firstName: (firstName), fullname: (fullName), lastname: (lastName), picture: (picture), email: (email)")

                print("ALL FIELDS PUBLISHED")


                if let delegate = self.responseDelegate
                delegate.responseUpdated(self.responseJSON, forLogin: "FB")


                case .failed(let error):
                print(error)


                }


                Hence when I got to it and confirmed my email address it gave me the email in response. Here are some attached snapshots.



                enter image description here



                enter image description here



                enter image description here



                This is how i got to it. Later I implemented that if the email is not returned, I showed an alert alerting the user that there is no email associated with that facebook account and either they confirm their email or proceed by giving a separate email address in an TextField Alert. And thats that.






                share|improve this answer

























                  0












                  0








                  0







                  Well i pondered on this for a long time and came upon this link which suggested that if you don't have a confirmed email address I won't get it back in the login section of my code.



                  let request = GraphRequest(graphPath: "me", parameters: ["fields": "id, email, name, first_name, last_name, picture.type(large)"], accessToken: AccessToken.current, httpMethod: .GET, apiVersion: "2.12")
                  request.start (response, result) in
                  switch result
                  case .success(let value):
                  print(value.dictionaryValue!)
                  self.responseJSON = JSON(value.dictionaryValue!)
                  let fullName = self.responseJSON["first_name"].stringValue
                  let firstName = self.responseJSON["first_name"].stringValue
                  let lastName = self.responseJSON["last_name"].stringValue
                  let email = self.responseJSON["email"].stringValue
                  let idFb = self.responseJSON["id"].stringValue
                  let picture = self.responseJSON["picture"]["data"]["url"].stringValue

                  print("user id: (idFb), firstName: (firstName), fullname: (fullName), lastname: (lastName), picture: (picture), email: (email)")

                  print("ALL FIELDS PUBLISHED")


                  if let delegate = self.responseDelegate
                  delegate.responseUpdated(self.responseJSON, forLogin: "FB")


                  case .failed(let error):
                  print(error)


                  }


                  Hence when I got to it and confirmed my email address it gave me the email in response. Here are some attached snapshots.



                  enter image description here



                  enter image description here



                  enter image description here



                  This is how i got to it. Later I implemented that if the email is not returned, I showed an alert alerting the user that there is no email associated with that facebook account and either they confirm their email or proceed by giving a separate email address in an TextField Alert. And thats that.






                  share|improve this answer













                  Well i pondered on this for a long time and came upon this link which suggested that if you don't have a confirmed email address I won't get it back in the login section of my code.



                  let request = GraphRequest(graphPath: "me", parameters: ["fields": "id, email, name, first_name, last_name, picture.type(large)"], accessToken: AccessToken.current, httpMethod: .GET, apiVersion: "2.12")
                  request.start (response, result) in
                  switch result
                  case .success(let value):
                  print(value.dictionaryValue!)
                  self.responseJSON = JSON(value.dictionaryValue!)
                  let fullName = self.responseJSON["first_name"].stringValue
                  let firstName = self.responseJSON["first_name"].stringValue
                  let lastName = self.responseJSON["last_name"].stringValue
                  let email = self.responseJSON["email"].stringValue
                  let idFb = self.responseJSON["id"].stringValue
                  let picture = self.responseJSON["picture"]["data"]["url"].stringValue

                  print("user id: (idFb), firstName: (firstName), fullname: (fullName), lastname: (lastName), picture: (picture), email: (email)")

                  print("ALL FIELDS PUBLISHED")


                  if let delegate = self.responseDelegate
                  delegate.responseUpdated(self.responseJSON, forLogin: "FB")


                  case .failed(let error):
                  print(error)


                  }


                  Hence when I got to it and confirmed my email address it gave me the email in response. Here are some attached snapshots.



                  enter image description here



                  enter image description here



                  enter image description here



                  This is how i got to it. Later I implemented that if the email is not returned, I showed an alert alerting the user that there is no email associated with that facebook account and either they confirm their email or proceed by giving a separate email address in an TextField Alert. And thats that.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Mar 25 at 4:47









                  Mohsin Khubaib AhmedMohsin Khubaib Ahmed

                  7751322




                  7751322



























                      draft saved

                      draft discarded
















































                      Thanks for contributing an answer to Stack Overflow!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid


                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.

                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f44551386%2fios-facebook-sdk-fbsdkgraphrequest-doesnt-return-email-swift%23new-answer', 'question_page');

                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

                      SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

                      은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현