skip to Main Content

I’m implementing sign-in via email link and I have it sending the email, but I’m using an email that has not been registered yet. Is there a way to detect if the email is already registered before calling sendSignInLinkToEmail? No error was reported from the call. TIA!

2

Answers


  1. Chosen as BEST ANSWER

    Nabil's answer led me to finding the function fetchSignInMethods, which was just the thing I needed. Posted here for anyone else looking for this.

            Auth.auth().fetchSignInMethods(forEmail: email, completion: {
                methods, error in
    
                if methods == nil {
                    self.showAlert(title: "This email is not registered, please create an account")
                    return
                }
            })
    

  2. Maybe this function can help you

    Auth.auth().fetchProviders(forEmail: emailAddress, completion: {
        error in
    
        if let error = error {
            print(error.localizedDescription)
        } else {
            //
        }
    })
    

    So that if the email doesn’t exist it’ll return an error otherwise you can run the sendSignInLinkToEmail function

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search