Search code examples
androidfirebasefirebase-authentication

Firebase check email exist (fetchProvidersForEmail alternative)


the fetchProvidersForEmail method is deprecated. But on the firebase site i dont find an alternative, so i have to ask you. Hope you can help.

I want to Check if email is not already in the database, here is the old code for that.

  Auth.fetchProvidersForEmail(Email.getText().toString()).addOnCompleteListener(new OnCompleteListener<ProviderQueryResult>() {
@Override
public void onComplete(@NonNull Task<ProviderQueryResult> task) {

Solution

  • As the documentation for fetchProvidersForEmail says:

    fetchProvidersForEmail(String email)

    This method was deprecated. This method is being renamed for functional clarity - please use the fetchSignInMethodsForEmail(String) method instead.

    If no account exists for the email, the SignInMethodQueryResult. getSignInMethods() will return an empty list.


    Note: since 2024 both fetchProvidersForEmail and fetchSignInMethodsForEmail are deprecated, due to the introduction and enforcement of protection against email enumeration attacks that these methods allow/enable.