Cannot read the NFC chip of the ePassport using iOS13
Asked Answered
K

1

10
import UIKit
import CoreNFC

class ViewController: UIViewController, NFCTagReaderSessionDelegate {

    var nfcTagReaderSession: NFCTagReaderSession?

    func tagReaderSessionDidBecomeActive(_ session: NFCTagReaderSession) {
        print("Tag reader did become active")
        print("isReady: \(nfcTagReaderSession?.isReady)")
    }

    func tagReaderSession(_ session: NFCTagReaderSession, didInvalidateWithError error: Error) {
        print("\(error)")
    }

    func tagReaderSession(_ session: NFCTagReaderSession, didDetect tags: [NFCTag]) {
        // this part is never called!
        print("got a Tag!")
        print("\(tags)")
    }

    @IBAction func clickedNFC(_ sender: Any) {
        nfcTagReaderSession = NFCTagReaderSession(pollingOption: [.iso14443], delegate: self)

        nfcTagReaderSession?.alertMessage = "Place the device on the innercover of the passport"
        nfcTagReaderSession?.begin()
        print("isReady: \(nfcTagReaderSession?.isReady)")

    }

}

I also have in my entitlements file

<key>com.apple.developer.nfc.readersession.formats</key>
<array>
    <string>NDEF</string>
    <string>TAG</string>
</array>

and in my Info.plist

<key>NFCReaderUsageDescription</key>
<string>Read the NFC chip of ePassports</string>
<key>com.apple.developer.nfc.readersession.iso7816.select-identifiers</key>
<array>
    <string>A0000002471001</string>
</array>

My problem is that tagReaderSession(_ session: NFCTagReaderSession, didDetect tags: [NFCTag]) is never being called. What am I missing?

Kinsey answered 9/6, 2019 at 15:12 Comment(0)
K
12

I found the solution I added 00000000000000 to the com.apple.developer.nfc.readersession.iso7816.select-identifiers entry in the Info.plist Now it looks like this:

<key>com.apple.developer.nfc.readersession.iso7816.select-identifiers</key>
<array>
    <string>A0000002471001</string>
    <string>00000000000000</string>
</array>
Kinsey answered 9/6, 2019 at 16:10 Comment(5)
Hi, anyone know where to find the information about this select-identifiers ?Walkthrough
I read that the German / EU passport is working with iso14443 but I can not get it working. Does anybody know if it should work with the new German passport?Rixdollar
It should work with the new one, what error do you get?Kinsey
From where to get data to pass in " NFCISO7816APDU(instructionClass:0, instructionCode:, p1Parameter:, p2Parameter:, data: HERE, expectedResponseLength:)"Mcgruder
ok, but WHY in plist? it should be in entitlements... reading apple docs..Gallego

© 2022 - 2024 — McMap. All rights reserved.