所以我正在使用Firebase进行此登录和注册屏幕,每当我格式化电子邮件错误或不使密码6个字母长时,我如何将其显示为警报?
这是我在我的firebase代码中使用的,第一个是定义字段中必须包含的内容,第二个是弹出警告,如果它不符合注册或登录信息的要求,你想要它说什么。
@objc private func registerButtonTapped() {
emailField.resignFirstResponder()
passwordField.resignFirstResponder()
firstNameField.resignFirstResponder()
lastNameField.resignFirstResponder()
guard let firstName = firstNameField.text,
let lastName = lastNameField.text,
let email = emailField.text,
let password = passwordField.text,
!email.isEmpty,
!password.isEmpty,
!firstName.isEmpty,
!lastName.isEmpty,
password.count >= 6 else {
alertUserLoginError()
return
}
func alertUserLoginError(message: String = "Please enter all information to create a new account.") {
let alert = UIAlertController(title: "Woops",
message: message,
preferredStyle: .alert)
alert.addAction(UIAlertAction(title:"Dismiss",
style: .cancel, handler: nil))
present(alert, animated: true)
}