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

1
fun onClickDeEnrollButton() {
2
try {
3
Keyless.deEnroll(null)
4
} catch(e: Exception) {
5
// handle exception
6
}
7
}
Copied!
Optionally, start a loading indicator and show the progress by implementing the following optional KeylessDelegate method:
KeylessDelegateCustom.kt
1
import android.util.Log
2
import io.keyless.sdk.api.AuthenticationFailed
3
import io.keyless.sdk.api.DeEnrollmentFailed
4
import io.keyless.sdk.api.KeylessDelegate
5
import io.keyless.sdk.api.KeylessException
6
​
7
class KeylessDelegateCustom : KeylessDelegate {
8
​
9
// ...
10
11
// Optional functions
12
13
override fun deEnrollmentStart() {
14
// Please make sure to use runOnUiThread() if you need to handle UI changes
15
}
16
​
17
// ...
18
}
Copied!

​
😎
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).
1
import android.util.Log
2
import io.keyless.sdk.api.AuthenticationFailed
3
import io.keyless.sdk.api.DeEnrollmentFailed
4
import io.keyless.sdk.api.KeylessDelegate
5
import io.keyless.sdk.api.KeylessException
6
​
7
class KeylessDelegateCustom : KeylessDelegate {
8
​
9
// ...
10
11
fun deEnrollmentFinish(deEnrollmentResponse: String?, error: DeEnrollmentFailed?) {
12
// Please make sure to use runOnUiThread() if you need to handle UI changes
13
if (error != null) {
14
// Failed to de-enroll
15
Log.e(TAG, "DeEnrollment failed: " + error.title +
16
" Message: " + error.message + " Code: " + error.code +
17
" Cancelled by user: " + error.userCancelled);
18
19
// Here you may want to display an error alert
20
return
21
}
22
​
23
// Reset app content, delete any user data
24
// at this point de-enrolling was successful
25
26
// Leave current view
27
// Navigate user to initial starting point of the app
28
}
29
​
30
// ...
31
}
32
​
33
​
Copied!
​
Export as PDF
Copy link