I have create user used as Admin in firebase auth. Now I want to login and use Admin account to delete other account by using their FIRAuth User UID. How to implement in swift?<
You can remove/delete user like this:
Note: Some security-sensitive actions—such as deleting an account, setting a primary email address, and changing a password—require that the user has recently signed in.
let credential: AuthCredential
user.reauthenticate(with:credential) { error in
if let error = error {
// An error happened.
showAlertWithErrorMessage(message: error.localizedDescription)
} else {
// User re-authenticated.
user.delete { error in
if let error = error {
// An error happened.
showAlertWithErrorMessage(message: error.localizedDescription)
} else {
// Account deleted.
Database.database().reference(fromURL: kFirebaseLink).child(kUser).child(userID).removeValue()
try! Auth.auth().signOut()
self.navigationController?.popToRootViewController(animated: true)
}
}
}
}
}else{
showAlertWithErrorMessage(message: "Try again later")
}
This way achieve delete user functionality in my ios app.(remove user from firebase authentication and database both side)
100% working and tested