De-enrollment
Example for how to de-enroll an existing user.

Trigger

This section shows how to remove a user from the Keyless network.
First, show an alert which allows the user to confirm that they wish to delete their account. After confirmation, prompt them to authenticate.
func tappedDeEnrollButton(_ sender: Any) {
do {
// Use challenge to retrieve an authentication token
try Keyless.shared.deEnroll(deEnrollmentChallenge: authenticationChallenge)
} catch {
// Handle error
print("DeEnrollment finished with error: \(error)")
}
}
Optionally, start a loading indicator and show the progress by implementing the following optional Keyless delegate method:
func deEnrollmentDidStart() {
DispatchQueue.main.async { [weak self] in
// Start loading indicator
}
}
When de-enrollment is complete, the deEnrollmentDidFinish method gets called.
Handle any errors and prompt the user to try again if it failed. If the process was successful, stop the loading indicator and navigate the user to the initial starting point of your app (e.g. onboarding screen, login screen).
func deEnrollmentDidFinish(deEnrollmentResponse: String?, error: KeylessError?) {
guard error == nil else {
print("deEnrollmentDidFinish with error: \(error!)")
DispatchQueue.main.async { [weak self] in
// Failed to de-enroll
// Show error alert
}
return
}
// reset app content, delete any user data
// at this point de-enrolling was successful
DispatchQueue.main.async { [weak self] in
// leave current view
// navigate user to initial starting point of the app
}
}
Export as PDF
Copy link