baumblatt / capacitor-firebase-auth

Capacitor Firebase Authentication Plugin
MIT License
261 stars 129 forks source link

Solution of Instance of firebase.auth.Auth must be passed as an argument #198

Open jamalroger opened 2 years ago

jamalroger commented 2 years ago

Hi all The solution for who had this issues followed

Either an instance of firebase.auth.Auth must be p…must be initialized via firebase.initializeApp().

Problem : the function cfaSignIn is called before firebase.initializeApp() that why these error is showed

Solution : Is to add Promise before called cfaSignIn

Exemple

import firebase from "firebase/app";
import "firebase/auth";
const firebaseConfig = {
  apiKey: "AIzaSyDPSXEvut47Th-lGUCfzJ0GFP6npsjkVvs",
  authDomain: "bricolo-849a3.firebaseapp.com",
  projectId: "bricolo-849a3",
  storageBucket: "bricolo-849a3.appspot.com",
  messagingSenderId: "869830848668",
  appId: "1:869830848668:web:0916859b14b8f9168bfd59",
  measurementId: "G-6L2Z1P2FC3",
};

auth = () => {
  return new Promise((ex, reject) => {
    try {
      firebase.initializeApp(firebaseConfig);
      ex();
    } catch (error) {
      reject;
    }
  });
};

auth().then(() => {
  cfaSignInGoogle().subscribe((user) => console.log(user));
});