How to fix error when running auth().signinwithcredential in Firebase Expo

22 views Asked by At

When I run auth().signInWithCredential I get the error:

No Firebase App '[DEFAULT]' has been created - call firebase.initializeApp()

I have provided my code below. I also created a firebase.js file with the config file I got from Firebase. I am sure it is not the problem, but what is and how can I solve it.

import { db } from "../firebase";
import auth from "@react-native-firebase/auth";
import { arrayUnion } from "firebase/firestore";
import { useEffect, useState } from "react";
import {
  GoogleSignin,
  GoogleSigninButton,
} from "@react-native-google-signin/google-signin";



useEffect(() => {
    GoogleSignin.configure({
      webClientId:
        "13653657738-te8npgeck2gcee4u33rrdjpf5u1sr1c9.apps.googleusercontent.com",
    });
  }, []);

  async function onGoogleButtonPress() {
    // await GoogleSignin.hasPlayServices();
    const { idToken } = await GoogleSignin.signIn();
    const googleCredential = auth.GoogleAuthProvider.credential(idToken);
    return auth().signInWithCredential(googleCredential);
  }


<TouchableOpacity
              onPress={() => {
                // navigation.navigate("Procedure");
                onGoogleButtonPress()
                  .then((val) => {
                   console.log("Hi")
            .then((valk) => {
              db.collection("users")
                .doc("userId")
                .update({ ids: arrayUnion(user.uid) })
                .then((vol) => {
                  navigation.navigate("Procedure");
                });
            });
            */
                    navigation.navigate("Procedure");
                  })
                  .catch((e) => {
                    console.log(e.message);
                  });
              }}
            >
              <Image
                source={require("../assets/googlebutton.png")}
                style={{ maxWidth: 350, maxHeight: 63 }}
                alt={"Google Button"}
              />
            </TouchableOpacity>
0

There are 0 answers