Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

76
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!