Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the Signed in Phone Number in Firebase Authentication for Android?

I am using Android Firebase Auth Ui for providing Phone Number based sign in option in an android app. I am trying to provide an additional option to signed in users to switch their signed in phone number to another number keeping the same user account.

But as per Firebase Docs for Phone number there are no options to change the signed in number.

There are options for linking different auth providers like email, google or Facebook login etc to same account. But there is no way mentioned about how to change the phone number or email id keeping the same user id.

Is there a workaround or method by which we can achieve this?

like image 957
Nithin Avatar asked Jun 17 '17 06:06

Nithin


People also ask

How to change phone number in Firebase authentication?

Create fictional phone numbers and verification codesIn the Firebase console, open the Authentication section. In the Sign in method tab, enable the Phone provider if you haven't already. Open the Phone numbers for testing accordion menu. Provide the phone number you want to test, for example: +1 650-555-3434.

How do I change the SMS verification template in Firebase phone Auth?

Neither the email verification template nor the SMS verification template can be modified. You can select the language from the Firebase console, however this is a per project setting and you can't modify the templates.

How do I change my number on Firebase Auth flutter?

On the Firebase Console, select the "Phone" authentication provider and click on the "Phone numbers for testing" dropdown. Enter a new phone number (e.g. +44 7444 555666 ) and a test code (e.g. 123456 ).

How do I authenticate a phone number?

What is phone number authentication? Phone number authentication is an authentication method in which a sender sends an SMS message to a receiver's phone. Then, the receiver logs into its phone with a one-time code provided in the SMS message.


1 Answers

I also had this challenge to update user phone number and when I go on documentation I got something by using I have done this task.

you can go for documentation by click here

Now the method you can use : - for java android project.

PhoneAuthCredential phoneAuthCredential = PhoneAuthProvider.getCredential( "+91-98298XXXX2", "OTP_CODE" );
// Update Mobile Number...
firebaseAuth.getCurrentUser().updatePhoneNumber(phoneAuthCredential)
    .addOnCompleteListener(new OnCompleteListener <Void>() {
        @Override
        public void onComplete(@NonNull Task <Void> task) {
            if (task.isSuccessful()) {
                // Update Successfully
            } else {
                // Failed
            }
        }
    }
);
like image 147
Shailendra Lodhi Avatar answered Oct 21 '22 09:10

Shailendra Lodhi