I have followed some tutorial but no one seams to work I need to get AuthErrorCode for firebase auth and Firestone for make the localizable this is my code
this is the login function where I need to call the errorHandlingFunction
Auth.auth().signIn(withEmail: emailTextField, password: passwordTextField) {result, error in
if error != nil {
self.alertMessage = self.errorHandling(error: error! as NSError)
self.showAlert.toggle()
self.isLoading = false
return
}
func errorHandling(error: NSError) -> String {
if let err = error as NSError?, let code = AuthErrorCode(rawValue: error.code)
{
switch code {
case .accountExistsWithDifferentCredential:
return String(localized: "Account already exist with different credetial", table: "Localization", comment: "alert message")
case .credentialAlreadyInUse:
return String(localized: "Credential are already in use", table: "Localization", comment: "alert message")
case .unverifiedEmail:
return String(localized: "An email link was sent to your account, please verify it before loggin in", table: "Localization", comment: "alert message")
case .userDisabled:
return String(localized: "User is currently disabled", table: "Localization", comment: "alert message")
case .userNotFound:
return String(localized: "Canno't find the user, try with different credential", table: "Localization", comment: "alert message")
case .weakPassword:
return String(localized: "Password is too weak", table: "Localization", comment: "alert message")
case .networkError:
return String(localized: "Error in network connection", table: "Localization", comment: "alert message")
case .wrongPassword:
return String(localized: "Password is wrong", table: "Localization", comment: "alert message")
case .invalidEmail:
return String(localized: "Email is not valid", table: "Localization", comment: "alert message")
default:
return String(localized: "Unknown error occurred", table: "Localization", comment: "alert message")
}
}
}
but I get this error from compiler
Cannot convert value of type 'Int' to expected argument type 'AuthErrorCode.Code'
is there a solution? and also for Firestone?
thanks