Backendless Support
 
Solved

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.

Leave a Comment

Comments (17)

photo
1

Hey Zeba

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

Regards, Vlad

photo
1

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.

photo
1

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

photo
1

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"]

photo
1

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.

photo
1

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.

photo
1

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

photo
1

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.

photo
1

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

photo
1

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

photo
photo
1

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.

photo
1

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:

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

And in appDelegate:

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

This prints " email is - Optional(332171971) "

photo
photo
1

Hi Zeba,

Fix has been made, please verify.

Regards Anton

photo
1

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

photo
photo
1

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".

photo
1

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

photo
1

Hi, Thanks! got it to work now.

photo