De-enrollment

Example for how to de-enroll an existing user.

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 of account deletion from the user, prompt them to authenticate to confirm deenrollment.

🔌 Trigger

fun onClickDeEnrollButton() {
try {
Keyless.deEnroll(null)
} catch(e: Exception) {
// handle exception
}
}

Optionally, start a loading indicator and show the progress by implementing the following optional KeylessDelegate method:

KeylessDelegateCustom.kt
import android.util.Log
import io.keyless.sdk.api.AuthenticationFailed
import io.keyless.sdk.api.DeEnrollmentFailed
import io.keyless.sdk.api.KeylessDelegate
import io.keyless.sdk.api.KeylessException
class KeylessDelegateCustom : KeylessDelegate {
// ...
// Optional functions
override fun deEnrollmentStart() {
// Please make sure to use runOnUiThread() if you need to handle UI changes
}
// ...
}

😎 Result

When de-enrollment is complete, the deEnrollmentFinish 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).

import android.util.Log
import io.keyless.sdk.api.AuthenticationFailed
import io.keyless.sdk.api.DeEnrollmentFailed
import io.keyless.sdk.api.KeylessDelegate
import io.keyless.sdk.api.KeylessException
class KeylessDelegateCustom : KeylessDelegate {
// ...
fun deEnrollmentFinish(deEnrollmentResponse: String?, error: DeEnrollmentFailed?) {
// Please make sure to use runOnUiThread() if you need to handle UI changes
if (error != null) {
// Failed to de-enroll
Log.e(TAG, "DeEnrollment failed: " + error.title +
" Message: " + error.message + " Code: " + error.code +
" Cancelled by user: " + error.userCancelled);
// Here you may want to display an error alert
return
}
// Reset app content, delete any user data
// at this point de-enrolling was successful
// Leave current view
// Navigate user to initial starting point of the app
}
// ...
}