iOS - linking a registered user to social accounts

Hello. I want to allow users to register via the normal backendless user registration process, and then connect their social accounts (fb, twitter, google & insta) so that they can login via these social accounts as well. I read the easy fb login doc and others but I couldn’t find anything about linking user accounts with their social accounts. Any pointers would be helpful! Thanks.

Hey Zeba

I’ve shared the topic with our iOS developer and he will answer you asap.

Regards, Vlad

Hi Vladimir,
Thanks for your response, I’ve been waiting, any pointers on how to do it? I need to deliver the app to my client.

Hi Zeba,

Sorry for waiting!
Yes you can implement merge between simple user account (email/password) and social account. But there are a few important points:

  1. In Users table field “email” must be “Identity” (by default)
  2. email in social account must be the same with user email in Users table

So, for example:
You have user with email "foo@bar.com" in your app, he can logout from the app and then login with Google/Fb/Twitter, and if his social account has email "foo@bar.com", this two accounts will be merged

Regards, Vlad

Hi Vlad,

Thanks for the help, I implemented twitter and fb. Facebook worked well, but when i logged in with twitter, it created a new user row in the data base. it had a number in the “email” field. Am i doing the mapping wrong? in mapping parameter i used - [“email”:“email”]

Hi Zeba,

seems that twitter user does not have email and has been registered via phone number. This is related to second statement of Vlad.

Hi Stanislaw,

The twitter account that i used to test this, has same email as one of the registered backendless user accounts. I just logged in with that email in twitter, to make sure of this.

If you create your own Twitter application you can set there “Request a User’s Email Address”. So after that you will receive user’s email.
Backendless Twitter app is for test purposes, not for production apps. Having your own twitter app will allow you to customize any way you want it.

Regards,
Stanislaw

Hi,

I have my own Twitter application and i have “Request a User’s Email Address” checked.
It’s still returning a numeric ID in the email field.

Hi again,

you’re right, I just made the same and has reproduced your issue.
I’ve created an internal ticket to fix this problem, you can reference it by it’s ID: BKNDLSS-14184.
Also I will notify you here once it will be fixed.
Thank you for being with us!

Regards,
Stanislaw

Thanks a lot for the quick support! I’ll wait.

Hi, Zeba Rahman.
We have fixed this problem. On the next day you can try again this functionality. We’ll be waiting for your response.

Hi Oleg, I tried now, it’s still returning a number. Maybe I’m not doing it right? Here’s the relevant portions of the code:


backendless?.userService.easyLogin(
            withTwitterFieldsMapping: ["name":"name","email":"email"],
            response: {(result) -> () in
        }, error: { (fault : Fault?) -> () in
        })

And in appDelegate:


func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool {
        let backendless = Backendless.sharedInstance()
        let user = backendless?.userService.handleOpen(url as URL!)
        if user != nil {
            let user = user as! BackendlessUser
            print("email is - \(user.email)")
        }
        return true
    }

This prints " email is - Optional(332171971) "

Hi Zeba,

Fix has been made, please verify.

Regards Anton

Hi Anton, I checked, it’s working now! Thank you so much!

Hi, I tried same thing with facebook easy login, and i’m facing a similar problem, the email in this case is returned as “nil”.

Hi,

please make sure again that you pass fieldsMapping and permissions for getting email field when calling loginWithFacebook. Also make sure your user has email in facebook.
If both conditions are met, then you should not have problems. I just checked and made sure this code works. Please let me know about your results.

Regards,
Stanislaw

Hi, Thanks! got it to work now.