Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check if an email address is already in use in Firebase on iOS?

I'm using the Firebase Authentication for my iOS App. Now I want to check that the entered email address is available or not. I have found that I have to use createUserWithEmailAndPassword for this. But the issue is I don't want to pass Password. I only want to check using Email. How can I do this?

like image 549
Sagar Unagar Avatar asked Dec 01 '22 11:12

Sagar Unagar


1 Answers

The following is the structure of the Firebase function you might be looking for (Swift 4):

Auth.auth().fetchProviders(forEmail: emailAddress, completion: {
        (providers, error) in

        if let error = error {
            print(error.localizedDescription)
        } else if let providers = providers {
            print(providers)
        }
    })

If the email address is already registered to a user, you will get a list of the providers that the email address is used for. Otherwise, the list of providers will be empty, and thus the email address is not registered.

like image 200
Erik P. Avatar answered Dec 04 '22 12:12

Erik P.