I'm trying to login to facebook using backendless easyLogin* method in Swift and to fetch user's facebook name to display further. I'm able to login successfully but can't get the name.
The code is as the following ("first_name"
is facebooks graph field to map, "displayName"
is backendless custom user field):
let backendless = Backendless.sharedInstance();
backendless.userService.easyLoginWithFacebookFieldsMapping(
["email":"email", "first_name":"displayName"], permissions: ["email", "public_profile"],
response: {(result : NSNumber!) -> () in
print ("Result: \(result)")
},
error: { (fault : Fault!) -> () in
print("Server reported an error: \(fault)")
})
What am I missing here?
Not sure what was the exact problem but the following worked for me:
I've removed previously created facebook user from backendless user table
Tried to login using the following code snippet:
func easyFacebookLogin() { let fieldsMapping = [ "name" : "name", "first_name": "first_name", "last_name" : "last_name", "email": "email"] backendless.userService.easyLoginWithFacebookFieldsMapping( fieldsMapping, permissions: ["email"], response: {(result : NSNumber!) -> () in print ("Result: \(result)") }, error: { (fault : Fault!) -> () in print("Server reported an error: \(fault)") }) }