【发布时间】:2021-03-01 09:54:37
【问题描述】:
我尝试从 FirebaseAuth 获取错误代码并显示与错误代码相关的内容。我尝试用开关来做到这一点:
Auth.auth().signIn(withEmail: email, password: password) { (user, error) in
if let error = error as? AuthErrorCode {
switch error {
case .emailAlreadyInUse:
Utility.showAlertView(with: "Email already used", and: "Please choose a different email adress", in: self)
case .invalidEmail:
Utility.showAlertView(with: "Email is invalid", and: "Please enter a valid email", in: self)
case .weakPassword:
Utility.showAlertView(with: "Weak Password", and: "Please Choose a longer Password", in: self)
default:
break
}
} else {
}
}
但我收到警告:
从 'Error' 转换为不相关的类型 'AuthErrorCode' 总是失败
我不知道该怎么办。 谢谢你的时间,Boothosh
【问题讨论】:
-
我已经检查过了,但我不明白我的代码有什么问题... :(
-
什么是
errror(有四个r)? ;-) -
是的,这是一个错误,但我在源代码中写的一切都很好
标签: swift firebase-authentication