Session Management

Manage verification session lifecycle, state, and timeouts.

Session Lifecycle

Each verification begins with creating a session, which progresses through several states:

createdwaitingForEngagementprocessingEngagementverifyingcompleted
failed or cancelled
StateDescription
createdSession created, ready to display QR or start NFC/BLE
waitingForEngagementWaiting for holder to respond (scan QR, tap NFC, connect BLE)
processingEngagementProcessing the holder's device engagement
readingDeviceReading data from the holder's device
verifyingValidating credentials with Owl Eyes API
completedVerification finished successfully
failedVerification failed (see error for details)
cancelledSession was cancelled by the app

Session Properties

The MDLSession object provides access to session information and state:

SessionProperties.swiftswift
Loading...

Observing Session State (SwiftUI)

Since MDLSession conforms to ObservableObject, you can observe state changes directly in SwiftUI:

SessionView.swiftswift
Loading...

Observing State with Combine

Use Combine publishers for more control over state observation:

VerificationViewController.swiftswift
Loading...

Session Timeouts

Sessions have a configurable timeout. After expiration, the session can no longer accept responses.

Configure Timeout

ConfigureTimeout.swiftswift
Loading...

Display Remaining Time

CountdownView.swiftswift
Loading...

Cancelling Sessions

Cancel a session when the user navigates away or wants to start over:

CancelSession.swiftswift
Loading...

Refreshing Session State

If needed, you can refresh the session state from the server:

RefreshSession.swiftswift
Loading...

Delegate Pattern (UIKit)

For UIKit apps or when you prefer delegation over Combine, implement the MDLVerifierDelegate:

DelegatePattern.swiftswift
Loading...

Best Practices

1. Handle Actor Isolation

The SDK uses @MainActor for UI safety. Ensure UI updates happen on the main actor:

ActorIsolation.swiftswift
Loading...

2. Clean Up Resources

Cleanup.swiftswift
Loading...

Next Steps