Firebase Reset Password Swift

Tyge picture Tyge · Mar 5, 2016 · Viewed 15.3k times · Source

I was wondering if you guys could show me how to setup Reset Password in Swift, I am currently using Firebase as my backend service. I just need the code.

Answer

Jay picture Jay · Mar 5, 2016

The answer is in the API documentation:

-sendPasswordResetWithEmail:completion:

Initiates a password reset for the given email address.

See FIRAuthErrors for a list of error codes that are common to all API methods.

In Swift 3.x and Firebase 3.x it will look like this:

FIRAuth.auth()?.sendPasswordReset(withEmail: "email@email") { error in
    // Your code here
}

Edit:

Firebase 4 changed the Firebase functions to be more aligned with the naming conventions in Swift.

Auth.auth().sendPasswordReset(withEmail: "email@email") { error in
    // Your code here
}