Easy Facebook Signup iOS - returned BackendlessUser object is useless

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.

Hi Beau,

Could you set a breakpoint right after you call handleOpenURL and then use the LLDB’s po command for the user object. Please let me know what output you see for that.

Regards,
Mark
p.s. I will pass your feedback on the support system to the company that makes this support software

I get this following the handleOpenURL

<BackendlessUser [<BackendlessUser: 0x7ff7935d5010>]> (null)

I can’t seem to add screenshots either using safari.

Screen Shot 2016-05-01 at 12.43.37 PM.png

Could you check what the record for that user is in Backendless console?

btw, here’s a screenshot I am posting from Safari:
http://support.backendless.com/public/attachments/108e25df5be5e17cfec058eed176a714.jpg</img>

Hmm maybe it’s when I try to add the image as an attachment, not inline. I don’t know. (Looks good on mobile by the way)

I do get a user created in the backendless database. Email is present, along with the social field being filled out. Even the other properties are being mapped correctly.

Just empty inside the app.

Thanks for helping me out with this.

I assume you have the latest version of the SDK (could you please double check?)

One other thing which would be quite useful is if you could use the Code Generation built into Backendless Console to create a project which includes the FB login code. You can do it by selecting the Code Generation icon in console, then click on iOS and select “Facebook login”. Scroll down the page and click “Download project”. This will give you a complete project which you should be able to run without any changes. Please check if that is working as expected.
http://support.backendless.com/public/attachments/aec6ea0b7be3f479890a9bcf749c080f.jpg</img>

If not, I’ll get someone from the dev team to look into it.

It’s definitely the latest version. I updated it a few days ago because the version I had before it (downloaded about a week before that) was showing an error in safari when trying to login through Facebook. (Latest version fixed this)

I’ll try this code generation in the morning and get back to you. Thanks again

Looks like everything is still empty even when using the generated code.

http://support.backendless.com/public/attachments/071bb39ed8189c41efacd3662b6906be.png</img>

071bb39ed8189c41efacd3662b6906be.png

Thanks for checking, Beau. I am assigning this to a developer to investigate further. Internal ticket # BKNDLSS-12544

Thank you :slight_smile:

Hi Beau,

I just created a simple project with easy FB login, it works fine for me, I shared it. You can try it with my backendless app, then set your appId & secretKey and compare the results. Let me know how it works for you.

Regards,
Slava

What do you mean by “it works fine”? How are you verifying that it works? Login isn’t an issue, your example does in fact do that quite well. However, I need to get some information out of the user object that is returned.

Try printing user.email, and it will return nil. Even in your example unfortunately.

Is this just the way the object is? If so, can we get this fixed, or at least suggest some kind of work around.

I’m going to check out the source code and see if I can find anything.

Thanks.

Alright so there’s a few areas to check out.

UserService.m -> handleOpenURL
UserService.m -> onLogin.
BackendlessUser -> assignProperties.

Not sure what this is:

http://bugs.backendless.com/browse/BKNDLSS-11936

AND why this
//id userData = [NSJSONSerialization JSONObjectWithData:[absoluteString dataUsingEncoding:NSUTF8StringEncoding] options:0 error:nil];

was commented out and replaced with this:

    id userData = [NSJSONSerialization JSONObjectWithData:[absoluteString dataUsingEncoding:NSUTF16StringEncoding] options:0 error:nil];

Somewhere along the line, these properties aren’t getting set correctly when they come back through the URL. I’m going to add more logging and see what I come up with.

So everything is coming back in the URL fine.
It’s the mapping.

Why is there no error checking on the JSON paresing?

AAAAAND there we go. No value for key in object around character 714.
Which just so happens to be around the last key, “objectId”.

Error Domain=NSCocoaErrorDomain Code=3840 "No value for key in object around character 714." UserInfo={NSDebugDescription=No value for key in object around character 714.}

And this is how it looks:

,"objectId"#_=_

You don’t even need the error to see this.
Just log the URL that is returned.

Can’t believe I missed that the first time.
Should have run it through a JSON validator.

One more thing, this needs some extra checking. Shouldn’t assume that if it’s not a backendlessUser object, it automatically means its an NSDictionary.

http://support.backendless.com/public/attachments/4741c59efa27346bba4caa1baeb60375.png</img>

So I think this might be an issue with the API not the SDK. Double checking.

Yup, API...t@icloud.com%22,%22objectId%22#=

Please fix, and roll out as soon as possible.

You wrote: “Try printing user.email, and it will return nil. Even in your example unfortunately”.

Well, I did it:
http://support.backendless.com/public/attachments/c7ba8976c5902d6ac0601ed2565aedb7.png</img>
And here is a log:
http://support.backendless.com/public/attachments/59e220b36040c50199e3e9f310c59fb9.png</img>
Hope you can see my email.

Please provide your screenshots.

And here is your record in my backendless app:
http://support.backendless.com/public/attachments/03b998722a19a90234bb64d470fded61.png</img>
So, “it works fine for me” - and it must be fine for you.