I’d like to first start by saying how flawed this support system is. At least on Safari. I wrote out a huge topic, only to asked to sign in (again) and have it all erased on me. Not only that, but there’s no way to end resizing this text view. It just keeps on following the mouse.
To my problem.
I have been trying to get the easy Facebook login method working for about 2 days now. (May have been easier doing it the regular way). I have followed the docs, (as far as I know), I have the app setup with Facebook, I have the keys added to the settings for my app in Backendless, and everything filled out in the .plist.
As far as I can tell, the login actually does work, however I can’t do anything with the user once they have been sent back to the app. All the properties on the user object are nil. Even the email.
This is how I start the login process.
@IBAction func connectWithFacebook(sender: UIButton) {
backendless.userService.easyLoginWithFacebookFieldsMapping(
["email":"email", "first_name":"firstName", "gender":"gender", "work":"work"], permissions: ["email","public_profile"],
response: {(result : NSNumber!) -> () in
print ("Result: \(result)")
},
error: { (fault : Fault!) -> () in
print("Server reported an error: \(fault)")
})
}
Then once back in the app, I recreate the view hierarchy so that I can get more information from the user. This will also profile any information I can find from their Facebook profile.
func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject) -> Bool {
print("AppDelegate -> application:openURL: \(url.scheme)")
let backendless = Backendless.sharedInstance()
if let user = backendless.userService.handleOpenURL(url) {
print("AppDelegate -> application:openURL: user = \(user)")
let root = window?.rootViewController
let intro = root?.storyboard?.instantiateViewControllerWithIdentifier("IntroViewController") as! IntroViewController
let navigationSignup = root?.storyboard?.instantiateViewControllerWithIdentifier("signupNavigationController") as! UINavigationController
let signupScreen = root?.storyboard?.instantiateViewControllerWithIdentifier("EmailSignupViewController") as! EmailSignupViewController
signupScreen.facebookUser = user as? BackendlessUser
signupScreen.delegate = intro
if window?.rootViewController?.presentedViewController != nil {
window?.rootViewController?.dismissViewControllerAnimated(false, completion: nil)
}
window?.rootViewController?.presentViewController(intro, animated: false, completion: nil)
intro.presentViewController(navigationSignup, animated: false, completion: nil)
navigationSignup.setViewControllers([signupScreen], animated: false)
}
return true
}
I get a crash anytime I try to access a property on the user object. Whether it be email, or gender, doesn’t matter, apparently it doesn’t exist.
I have also tried accessing the user by currentUser() but this doesn’t work either.
I know the login has worked, as there is a new entry in the backendless database. It’s just this particular userService.handleOpenURL() doesn’t seem to be giving me what I need.
Am I doing something wrong? Please tell me it’s just a silly mistake.
Thanks.