Hey guys! Thanks for this great platform.
Im implementing FB login through your tutorial using FB SDK. It´s “working” but the user being returned has name = “<null>”; Therefore when I try to access it I get a nil object.
When I directly print it from the FB I get: name = “An\U00edbal Alejandro Madrid”;
My name is Aníbal Alejandro Madrid. I guess the í could be messing it up?
This is the field mapping im using:
let fieldsMapping = [
“id” : “facebookId”,
“name” : “name”,
“birthday”: “birthday”,
“first_name”: “fb_first_name”,
“last_name” : “fb_last_name”,
“gender”: “gender”,
“email”: “email”
]
Hi Anibal,
I just checked this issue - FB Login works fine for me.
Here is my sample code.
AppDelegate.m:
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
let APP_ID = "1C5B19B3-953D-9548-FF59-95999A2FE800"
let SECRET_KEY = "CE0A96CD-0421-B988-FF80-E16A6A8F7200"
let VERSION_NUM = "v1"
var backendless = Backendless.sharedInstance()
func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject) -> Bool {
print("AppDelegate -> application:openURL: \(url.scheme)")
let result = FBSDKApplicationDelegate.sharedInstance().application(application, openURL: url, sourceApplication: sourceApplication, annotation: annotation)
if result {
let token = FBSDKAccessToken.currentAccessToken()
let fieldsMapping = [
"id" : "facebookId",
"name" : "name",
"birthday": "birthday",
"first_name": "first_name",
"last_name" : "last_name",
"gender": "gender",
"email": "email"
]
backendless.userService.loginWithFacebookSDK(
token,
fieldsMapping: fieldsMapping,
response: { (user: BackendlessUser!) -> Void in
print("user: \(user)")
},
error: { (fault: Fault!) -> Void in
print("Server reported an error: \(fault)")
})
}
return result
}
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
backendless.initApp(APP_ID, secret:SECRET_KEY, version:VERSION_NUM)
return FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)
}
}
ViewController.m:
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let loginButton = FBSDKLoginButton()
loginButton.center = self.view.center
self.view.addSubview(loginButton)
}
}
Here is app log (you can see all mapped fields which are returned by server):
http://support.backendless.com/public/attachments/0571bb631e16ccd017ccdc6407b0c48b.png</img>
and my Backendless app dashboard:
http://support.backendless.com/public/attachments/45a86a2f6c9e2d1c26f382ad822d3848.png</img>
You should download the latest release of libs from github:
- backendless
- CommLibiOS
and try again.
Also you could try my sample code with my appID & secretKey (here above).
Regards,
Slava