createProximityPresentationSession

suspend fun createProximityPresentationSession(    activity: Activity,     authenticationOption: AuthenticationOption = AuthenticationOption.Signature,     bleMode: BleMode = BleMode.MDocClientCentral,     onRequestReceived: ProximityPresentationSession.OnRequestReceived,     onConnected: ProximityPresentationSession.OnConnected? = null,     onSessionTerminated: ProximityPresentationSession.OnSessionTerminated? = null): ProximityPresentationSession

Create a proximity based presentation session with a mobile credential verifier using device retrieval as per ISO/IEC 18013-5:2021.

This function requires the following Bluetooth-related permissions to be granted to the calling application:

For Android versions R and below:

  • android.permission.BLUETOOTH

  • android.permission.BLUETOOTH_ADMIN

  • android.permission.ACCESS_FINE_LOCATION

  • android.permission.ACCESS_COARSE_LOCATION

For Android versions R and above:

  • android.permission.BLUETOOTH_SCAN

  • android.permission.BLUETOOTH_ADVERTISE

  • android.permission.BLUETOOTH_CONNECT

If the application using this SDK hasn't already tried to use Bluetooth before, calling this function will result in a system UI prompt asking the user to grant the application permission to use Bluetooth. However, if the user has already been asked for this permission, either through interaction with another part of the application or through a prior call to this function made by the app and they denied the request, then the HolderException.BluetoothPermissionException exception will be thrown in response until the user explicitly grants the application Bluetooth permission in their OS app settings.

This function throws exceptions in case a session cannot be established.

If an issue occurs after the session is established, the related exception will be shared in onRequestReceived or onSessionTerminated callback.

onRequestReceived exceptions

In the event of an error onRequestReceived callback can produce the following:

onSessionTerminated exceptions

onSessionTerminated is invoked when a session is terminated:

Incoming message from verifier cannot be processed due to invalid CBOR format or a cryptography-related issue.HolderException.SessionTerminatedException.SessionStatusCodeSentException
The verifier indicated that they cannot process a message from the holder due to invalid CBOR format or a cryptography-related issue.HolderException.SessionTerminatedException.SessionStatusCodeReceivedException
The holder terminates the session by calling ProximityPresentationSession.terminateSessionnull
The verifier terminates the session.null
BLE connection lost.HolderException.DataTransportDisconnectedException
Session timeout.HolderException.InactivitySessionTimedOutException

Return

The newly created ProximityPresentationSession instance.

Parameters

authenticationOption

Device authentication option to be used for mobile credentials which are presented in the established session. If left unspecified, the signature based mode is used.

bleMode

Specifies which BLE based mode to use for data transfer in the established session. If left unspecified, the mDocClientCentral mode is used.

onRequestReceived

Callback, triggered when a request to present mobile credentials is received.

onConnected

Callback, triggered when a connection has been established with a mobile credential verifier.

onSessionTerminated

Callback, triggered when a data transport session has been terminated.

Throws

If the SDK API is called before the SDK is initialized.

If the provided authentication option is not supported.

If Bluetooth permissions are denied.

If Bluetooth is disabled on the device.

For unexpected runtime errors.

This exception is re-thrown, but not caught or handled further in this method.