FirebaseAuth.Instance is null xamarin forms

141 views Asked by At

FirebaseAuth.Instance is null in xamarin forms tried updating package removing package, unable to solve the problem

enter image description here

public async Task<bool> LoginUser(string Email, string Password)
    {            
        try
        {
            await FirebaseAuth.Instance.SignInWithEmailAndPasswordAsync(Email, Password);
            return true;
        }
        catch (FirebaseAuthWeakPasswordException ex)
        {
            throw new Exception(ex.Message);
        }
        catch (FirebaseAuthInvalidCredentialsException ex)
        {
            throw new Exception(ex.Message);
        }   
        catch (FirebaseAuthInvalidUserException ex)
        {
            throw new Exception("There is no user record corresponding to this identifier");
        }            
        catch (Exception ex)
        {
            throw new Exception("There was an unkown Error."); 
        }   
    }
1

There are 1 answers

0
Abuelhija On
  1. install Xamarin.GooglePlayServices.Base
  2. include google-services.json with the 'GoogleServicesJson' build action
  3. invoke Firebase.FirebaseApp.InitializeApp(this); in MainActivity.onCreate() method.