collectUserKey
Collects a user key selection from the user via a Jetpack Compose dialog.
This suspending function displays a modal dialog that prompts the user to select one of their registered device binding keys when multiple keys exist for the same application. This scenario occurs when:
Multiple users have registered device bindings on the same device
A single user has multiple device bindings with different authentication types
The dialog is displayed as an overlay on top of the provided activity using a ComposeView, ensuring a consistent Material Design UI experience.
The function suspends until the user either:
Selects a user key and confirms it (returns the selected UserKeyOption)
Cancels the dialog (throws a RuntimeException)
Usage Scenarios
Multi-User Device
When multiple users have registered their credentials on a shared device, this dialog allows each user to select their own key for authentication:
UI Lifecycle
The dialog is implemented using Jetpack Compose and is added to the activity's content view hierarchy. When the user completes or cancels key selection, the dialog is automatically removed from the view hierarchy. If the coroutine is cancelled externally, the cleanup is handled automatically via kotlinx.coroutines.CancellableContinuation.invokeOnCancellation.
Integration with Device Binding
This function is automatically invoked by the device binding framework when:
A signing operation requires user key selection
Multiple keys are available in storage
No custom user key collector has been configured
Custom implementations can be provided via com.pingidentity.device.binding.authenticator.UserKeyAuthenticator configuration.
Return
The UserKeyOption selected by the user.
Parameters
The Android Activity that will host the user key selection dialog. This activity's UI thread is used for view operations.
The list of available user keys to display for selection. Defaults to an empty list. If empty, the dialog will show no options.
See also
Throws
if the user cancels the key selection dialog by pressing Cancel, back button, or dismissing the dialog.