Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

200
Visualizações
How can I update mobile number in firebase authentication using the updateProfie Method?

I am collecting name, email, phone and password when a user sign up. In the useFirebase hook, I am updating the displayName using updateProfile method of firebase.

This function is used for creating user.

const userCreate = (name, email, password, phone, history) => {
    createUserWithEmailAndPassword(auth, email, password)
        .then((userCredential) => {
            //User Create after registration
            const newUser = { email, displayName: name, phoneNumber:phone };
           const uid = auth.currentUser.uid
            verifyEmail();
            updateProfile(auth.currentUser, {
                displayName: name, 
                phoneNumber:phone,
            })
                .then(() => {
                    console.log()
                })
                .catch((error) => {
                });
            history.replace('/');
        })
        .catch((error) => {
            console.log(error)
        })
}

After signup the displayName is updated. But I am not getting the phone number. How can I do that?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

From the documentation on updating a user's profile:

You can update a user's basic profile information—the user's display name and profile photo URL—with the updateProfile method.

So there's no way to update the user's phone number with this function. The reason for this is that the phone number is part of a user's sign-in credentials, so needs to be updated through a dedicated method (similar to their password and email).

To update a user's phone number, call the updatePhoneNumber function as shown here:

// 'recaptcha-container' is the ID of an element in the DOM.
const applicationVerifier = new RecaptchaVerifier('recaptcha-container');
const provider = new PhoneAuthProvider(auth);
const verificationId = await provider.verifyPhoneNumber('+16505550101', applicationVerifier);
// Obtain the verificationCode from the user.
const phoneCredential = PhoneAuthProvider.credential(verificationId, verificationCode);
await updatePhoneNumber(user, phoneCredential);
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda