Skip to content

Reader

MdocReader

Now that you have created the ReaderSettings object you can initialize the MdocReader using the ReaderSettings that we have create before:

let mdocReader = MdocReader(readerSettings: settings) 

To present the scanner you need to call the presentQRScanner method like this:

mdocReader.presentQRScanner()

MdocReaderDelegate

After initializing the MdocReader and present the qr to your app, you need to implement the MdocReaderDelegate in order to capture the data from the document that you scanned. MdocReaderDelegate contains 4 delegate methods.

func didEventOccurred(_ event: MValidSdk.TransferEvent) {
    print("Event occurred: \(event)")
    // handle the event
}

func didFailWithError(_ error: LocalizedError) {
    print(error.localizedDescription)
    // handle the error
}

func didScanQRCode(_ qrCode: String) {
    print(qrCode)
    // handle the qrCode string
}

func didReceiveResponse(_ mdocResponse: MValidSdk.MdocResponse) {
    // handle the data as MdocResponse object
}