21

I am currently using Email and Phone number authentication using Firebase.

And i have 3 EditText for:

  • Email
  • Phone Number
  • Password

But the problem is when the user is done registering it obviously creates 2 instance of accounts, one for the Email and second for the Phone number.

I would like to link the Email and Phone number together as one account. Is there any way to do that?

1
  • Did you get any solution? I am facing the same issue. Commented Jun 30, 2021 at 11:31

1 Answer 1

18

Depending on whether you want to allow for signing in with either email or phone number, or if you want to allow for the Phone number to be used as a second factor, for sign in, there are different solutions.

If you just want to have the Phone number be a second way to sign in, you can link the credentials using the linkWithCredential method on your Firebase User. This way you can add as many ways to sign in, as you want. Firebase has a good guide on this.

If you want the phone number to be a second factor of authentication, you will need to have a custom auth provider, which does the second factor authentication. There is also a getting started guide on this, however the 2 Factor Authentication part itself would be up to you.

Sign up to request clarification or add additional context in comments.

1 Comment

Can you show us code with whole answer - first sign up with email, then do the phone auth and put it into the same userid (without creating a new user id)... I am having some issue with PhoneAuthCredential credential = PhoneAuthProvider.getCredential(VerificationId, code);

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.