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

77
Visualizações
Google Firebase authentication in ReactNative App

I was developing an app which I like implements Firebase as Authenticating system.

My problem comes when I try to set up the Authentication with Google provider when I try to modify the colletion of firestore where the users are saved. My code is the following:

export const loginWithGoogle = () => {
  const navigation = useNavigation();
  useEffect(() => {
    setTimeout(() => {
      navigation.navigate('/RegisterScreen');
    }, 10000);
  }, []);

  return () => {
    return firebase
      .auth()
      .signInWithPopup(Providers.google)
      .then(async result => {
        //console.log(result.credential.accessToken);
        const user = result.user;
        console.log(user);

        //This 2 lines below doesn't work to get the colletion.
        db.('users').setItem('userid', user!.uid);
        collection.(db,'users').setItem('photoURL', user!.photoURL);

        //TODO if userid exists IN USERS db then use update IF NULL use set
        await db.collection('users').doc(user!.uid).update({
          // id: user.uid,
          name: user!.displayName,
          email: user!.email,
          phone: user!.phoneNumber,
          photoURL: user!.photoURL,
        });
      })
      .then(() => {
        navigation.navigate('ProtectedScreen');
      })
      .catch(err => {
        console.log(err);
      });
  };
};

So I guess that my error comes from unknowledge of how to manage data saved on firestore.

If you can help take thanks in advance !

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

0

There are some thing we need to clear here:

You can just merge the data. There is no need to read/get it from Firestore to check if it is there and save it onyl if it's not. You will be charged for reads and writes. In the end it's cheaper to always just write without checking if something exists.

Also this code here:

db.('users').setItem('userid', user!.uid);
collection.(db,'users').setItem('photoURL', user!.photoURL);

especially with the db.( and collection.( doens't look good. Even if it is it's not for getting data but for saving it.

Could you pls clarify witch Firebase SDK you use: version 8 or 9. Also pls check a little bit the docs here.

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