Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

79
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda