swift - IOS Facebook SDK: login doesn't return email despite permissions granted -


i'm trying information through facebook sdk far i'm getting id , name of user, although i'm sure there email available, account. i've been looking @ several answer here none of them solved problem far. doing wrong, , why not returning more data requesting several permissions?

here code:

fbloginmanager.loginwithreadpermissions(["public_profile", "email", "user_friends", "user_about_me", "user_birthday"], handler: { (result, error) -> void in         if ((error) != nil)         {             // process error             println("there error: \(error)")         }         else if result.iscancelled {             // handle cancellations             fbloginmanager.logout()         }         else {             var fbloginresult : fbsdkloginmanagerloginresult = result             if(fbloginresult.grantedpermissions.contains("email"))             {                 println(fbloginresult)                 self.returnuserdata()             }         }     }) 

and function user data:

func returnuserdata() {     let graphrequest : fbsdkgraphrequest = fbsdkgraphrequest(graphpath: "me", parameters: nil)     graphrequest.startwithcompletionhandler({ (connection, result, error) -> void in          if ((error) != nil)         {             // process error             println("error: \(error)")         }         else         {             println("fetched user: \(result)")              if let username : nsstring = result.valueforkey("name") as? nsstring {                 println("user name is: \(username)")             }             if let useremail : nsstring = result.valueforkey("email") as? nsstring {                 println("user email is: \(useremail)")             }         }     }) } 

which returns:

fetched user: { id = 55555555; name = "kali aney"; } user name is: kali aney 

facebook graph api broke it’s backward compatibility (when used in default fashion) since graph-api version 2.4 (pod version 4.4.0).

fb graph-api 2.4 not return default fields user

to resolve can either use explicitly graph version 2.3:

[[fbsdkgraphrequest alloc] initwithgraphpath:@"me" parameters:nil tokenstring:[fbsdkaccesstoken currentaccesstoken].tokenstring version:@"v2.3" httpmethod:nil]

in case fb assures v2.3 available @ least 2 years now. https://developers.facebook.com/docs/graph-api/overview:

the graph api has multiple versions available access @ 1 time. each version contains set ofcore fields , edge operations. make guarantee core apis available , un-modified in version @ least 2 years release. platform changelog can tell versions available.

or

you can use new graph-api (v2.4) in asking specific fields interested in:

[[fbsdkgraphrequest alloc] initwithgraphpath:@"me" parameters:@{@"fields" : @"email,name"}]


Comments

Popular posts from this blog

Android : Making Listview full screen -

javascript - Parse JSON from the body of the POST -

javascript - Chrome Extension: Interacting with iframe embedded within popup -