sendCommand(apdu:completionHandler:)
Sends an application protocol data unit (APDU) to the tag and receives a response APDU.
Declaration
func sendCommand(apdu: NFCISO7816APDU, completionHandler: @escaping @Sendable (Data, UInt8, UInt8, (any Error)?) -> Void)func sendCommand(apdu: NFCISO7816APDU) async throws -> (Data, UInt8, UInt8)Parameters
- apdu:
An application protocol data unit to send to the tag.
- completionHandler:
A handler that the reader session invokes after the operation completes. The handler has the following parameters:
- responseData
The response data, which may be empty even if the operation completes successfully.
- sw1
The SW1 command-processing status byte. This value is always valid.
- sw2
The SW2 command-processing status byte. This value is always valid.
- error
nilwhen the operation completes successfully; otherwise, an Nserror object when there’s a communication issue with the tag.
Discussion
When you send a SELECT command with a p1Parameter value of 0x04, your app must support one of the applications listed in the ISO7816 application identifiers for NFC Tag Reader Session property list key. Otherwise, the completionHandler receives an NFCReaderError.Code.readerErrorSecurityViolation error.
The session calls completionHandler on the dispatch queue that you provided when creating the NFCTagReaderSession object.