confirmBtn.addTarget(self, action: #selector(changePassword(email:currentPassword:newPassword:completion:)), for: .touchUpInside)
}
func changePassword(email: String, currentPassword: String, newPassword: String, completion: @escaping (Error?) -> Void) {
let credential = EmailAuthProvider.credential(withEmail: email, password: currentPassword)
Auth.auth().currentUser?.reauthenticate(with: credential, completion: { (result, error) in
if let error = error {
completion(error)
}
else {
Auth.auth().currentUser?.updatePassword(to: newPassword, completion: { (error) in
completion(error)
})
}
})
}
Asked
Active
Viewed 36 times
0

AppleLog
- 1
-
1Have you tried marking the function with @objc attribute so that `@objc func changePassword(email:_, currentPassword:_, newPassword:_, completion:_)`? @objc attribute exposes the function to the Obj-C runtime. – Daniel Arden May 11 '21 at 15:20
-
Side note, you won't have the parameters. You don't send parameters with `addTarget()`. On `touchUpInside`, it will be called. Instead read the value of your `UITextField` (I guess). – Larme May 11 '21 at 15:28
-
1Not enough info, but possible duplicate of https://stackoverflow.com/q/24814646/10853463 – red_menace May 11 '21 at 15:53