present With
Start the process of presenting a set of Attestations to a relying party requested via an URL.
Return
a Flow of PresentationEvents.
Example usage for Android:
var infoResult: CompletableDeferred<Unit>? = null
var attestationSelectionResult: CompletableDeferred<String>? = null
suspend fun startPresentationWith(requestUri: String) {
walletSdk.presentations.presentWith(requestUri).collect { event ->
when (event) {
is PresentationEvent.InfoEvent -> {
val presentationRequest = event.presentationRequest /
// show in app what's requested
infoResult = event.result
}
is PresentationEvent.AttestationSelectionEvent -> {
val attestations = event.attestations
// show in app list of attestations matching the request
attestationSelectionResult = event.result
}
PresentationEvent.InvalidRequestEvent,
is PresentationEvent.NotImplementedEvent,
PresentationEvent.ParsingErrorEvent
is PresentationEvent.ErrorEvent,
is PresentationEvent.PresentationFailedEvent,
-> {
// handle error in app
}
is PresentationEvent.PresentationSuccessEvent -> {
// show success
}
}
}
}
// if current flow item is InfoEvent, go on with completing the InfoResult. This will trigger the SDK to
// return a PrestationEvent.AttestationSelectionEvent with a list of attestations matching the request
fun showMatchingCredentials() {
infoResult?.complete(Unit)
infoResult = null
}
// if current flow item is AttestationSelectionEvent, go on with completeting the AttestationSelectionResult
// and pass the attestationId of the selected Attestation. This will trigger the SDK to present the
// selected attestation with all its claims to the verifying party.
fun presentSelectedAttestation(attestationId: String) {
attestationSelectionResult?.complete(attestationId)
attestationSelectionResult = null
}Content copied to clipboard
Example usage for iOS:
public func presentWith(requestUri: String) async throws(PresentationError) {
for await value in WalletSdk.shared.presentWith(requestUri: requestUri) {
if let error = PresentationError.from(event: value) {
throw error
}
switch onEnum(of: value) {
case .infoEvent(let _info):
// show in app what's requested
// Trigger to get a list of matching attestations
_info.result.complete(value: KotlinUnit())
continue
case .attestationSelectionEvent(let _selection):
// show in app list of attestations matching the request
// Trigger to present the selected attestation
_selection.result.complete(value: "your_selected_id_here")
continue
case .presentationSuccessEvent(let _event):
// show success
return
default:
// check if we are missing a new error code / event
// in PresentationError.from(event: value)
// handle error in app
}
}
}Content copied to clipboard
Parameters
request Uri
the URL passed from e.g. a scanned QR-Code at a relying party's login page or a deeplink.