MaxKrissigo MaxKrissigo - 10 months ago 57
Swift Question

Firebase 3.6.0 (Auth) - Detecting the specific error - Swift 3.0

I'm trying to work out how to detect a certain error. Say the login failed, I want to check if the error was say the account entered doesn't exist, and then tell the viewer that. Same goes with all of the other errors if possible.

In Parse I would check if the error.code was equal to a certain number, not sure if it's the same or anything similar to Firebase.

Any help is appreciated!

Answer Source

Use this:-

if let errCode = FIRAuthErrorCode(rawValue: err!._code) {

                switch errCode {
                case .errorCodeInvalidEmail:
                    print("invalid email")
                case .errorCodeEmailAlreadyInUse:
                    print("in use")
                    print("Other error!")


Where err is the received error from firebase