scanNfcMdocReader

suspend fun scanNfcMdocReader(message: String?, options: MdocTransportOptions, transportFactory: MdocTransportFactory = MdocTransportFactory.Default, selectConnectionMethod: suspend (connectionMethods: List<MdocConnectionMethod>) -> MdocConnectionMethod?, negotiatedHandoverConnectionMethods: List<MdocConnectionMethod>, onHandover: suspend (transport: MdocTransport, encodedDeviceEngagement: ByteString, handover: DataItem, updateMessage: (message: String) -> Unit?) -> Unit): Boolean

Performs NFC engagement as a reader.

This uses scanNfcTag to show a dialog prompting the user to tap the mdoc.

When a connection has been established, onHandover is called with the created transport as well as the device engagement and handover structures used.

If the given transport is for org.multipaz.mdoc.connectionmethod.MdocConnectionMethodNfc the onHandover callback is called in the same coroutine used for interacting with the tag to ensure continued communications with the remote NFC tag reader and the updateMessage parameter to onHandover will be non-null which the application can use to update the message in the NFC scanning dialog. Otherwise onHandover is called in the calling coroutine right after the NFC interaction with updateMessage set to null. In either case, any exception thrown in onHandover will be thrown from this method.

Return

true if onHandover was invoked, false if no handover happened.

Parameters

message

the message to display in the NFC tag scanning dialog or null to not show a dialog. Not all platforms supports not showing a dialog, use org.multipaz.nfc.nfcTagScanningSupportedWithoutDialog to check at runtime if the platform supports this.

options

the MdocTransportOptions used to create new MdocTransport instances.

transportFactory

the factory used to create MdocTransport instances.

selectConnectionMethod

used to choose a connection method if the remote mdoc is using NFC static handover.

negotiatedHandoverConnectionMethods

the connection methods to offer if the remote mdoc is using NFC Negotiated Handover.

onHandover

: Will be called on successful handover.