Hier ist neues Format mit Benachrichtigung
Auth.auth().createUser(withEmail: email, password: password) { (user: User?, error) in
if error != nil {
if let errCode = AuthErrorCode(rawValue: error!._code) {
switch errCode {
case .invalidEmail:
print("invalid email")
// Create an alert message
let alertMessage = UIAlertController(title: "Invalid Email", message: "Please check the entered email address", preferredStyle: .alert)
// Attach an action on alert message
alertMessage.addAction(UIAlertAction(title: "OK", style: .default, handler: { (action) in
alertMessage.dismiss(animated: true, completion: nil)
}))
// Display the alert message
self.present(alertMessage, animated: true, completion: nil)
case .emailAlreadyInUse:
print("in use")
// Create an alert message
let alertMessage = UIAlertController(title: "Existed Email", message: "The email existed in our database, login instead of registering", preferredStyle: .alert)
// Attach an action on alert message
alertMessage.addAction(UIAlertAction(title: "OK", style: .default, handler: { (action) in
alertMessage.dismiss(animated: true, completion: nil)
}))
// Display the alert message
self.present(alertMessage, animated: true, completion: nil)
case .weakPassword:
print("password is weak")
// Create an alert message
let alertMessage = UIAlertController(title: "Password is weak", message: "Use upper and lower characters along with numbers", preferredStyle: .alert)
// Attach an action on alert message
alertMessage.addAction(UIAlertAction(title: "OK", style: .default, handler: { (action) in
alertMessage.dismiss(animated: true, completion: nil)
}))
// Display the alert message
self.present(alertMessage, animated: true, completion: nil)
default:
print("Other error!")
}
}
}
http://stackoverflow.com/questions/37449919/Lesen-Firebase-Auth-Fehler-geworfen-Firebase-3-x-und-swift Frage beantwortet hier, gleichen Code Dravidian geschrieben – Rialcom
Ich konnte nichts finden whil Ich suche im Voraus, danke, dass ich darauf hingewiesen habe. –
@Rialcom das ist nicht die gleiche Antwort. In swift3 müssen Sie auf Ihren Fehler als '._code' zugreifen. – Dravidian