ios - Firebase Authentication Error Handling -
not sure if somewhere already, couldn't find made it. hope provides someone. steps have follow:
step #1 put guard statement after try login
step #2 call fireerrorhandle function
that's , enjoy!
guard let error = autherrorcode(rawvalue: (error?._code)!) else { return } fireerrorhandle(code: error) func fireerrorhandle(code: autherrorcode) { switch code { case .invalidcustomtoken: print("indicates validation error custom token") case .customtokenmismatch: print("indicates service account , api key belong different projects") case .invalidcredential: print("indicates idp token or requesturi invalid") case .userdisabled: print("indicates user's account disabled on server") case .operationnotallowed: print("indicates administrator disabled sign in specified identity provider") case .emailalreadyinuse: print("indicates email used attempt sign in use.") case .invalidemail: print("indicates email invalid") case .wrongpassword: print("indicates user attempted sign in wrong password") case .toomanyrequests: print("indicates many requests made server method") case .usernotfound: print("indicates user account not found") case .accountexistswithdifferentcredential: print("indicates account linking required") case .requiresrecentlogin: print("indicates user has attemped change email or password more 5 minutes after signing in") case .provideralreadylinked: print("indicates attempt link provider account linked") case .nosuchprovider: print("indicates attempt unlink provider not linked") case .invalidusertoken: print("indicates user's saved auth credential invalid, user needs sign in again") case .networkerror: print("indicates network error occurred (such timeout, interrupted connection, or unreachable host). these types of errors recoverable retry. @cnsunderlyingerror field in @c nserror.userinfo dictionary contain error encountered") case .usertokenexpired: print("indicates saved token has expired, example, user may have changed account password on device. user needs sign in again on device made request") case .invalidapikey: print("indicates invalid api key supplied in request") case .usermismatch: print("indicates attempt made reauthenticate user not current user") case .credentialalreadyinuse: print("indicates attempt link credential has been linked different firebase account") case .weakpassword: print("indicates attempt set password considered weak") case .appnotauthorized: print("indicates app not authorized use firebase authentication provided api key") case .keychainerror: print("indicates error occurred while attempting access keychain") default: print("indicates internal error occurred") } }
Comments
Post a Comment