MiFare and iOS 13 – SAK and ATQA reading

Forum / MIFARE and NFC Reader IC`s / MiFare and iOS 13 – SAK and ATQA reading

Tagged: , , ,

  • 16. March 2020 at 14:19
    Hi,

    I have a set of MIFARE cards, I'd like my iOS app to read data from. In specific these are the models:

    1) MIFARE PLUS EV1 4k, 7 byte UID
    2) MIFARE PLUS S 4k, 4 byte NUID
    3) MIFARE DESFIRE EV2 2k, 7 byte UID

    In iOS 13, Apple extended the support to read MIFARE tags and following the example available at the following link, I managed to integrate the code in my app to read the identifier, myfareFamily and historicalBytes (ATS) of my MIFARE card:

    https://developer.apple.com/documentation/corenfc/building_an_nfc_tag-reader_app

    What I need to accomplish right now is reading the ATQA and SAK of a MIFARE card, but I am really having hard time understanding how to do it.
    Online I couldn't find any relevant example on how to read these tags, so I would like to know if it is possible with the API that Apple provides in iOS 13, to read these tags.
    I tested the reading-tags functionality, using an app called "NFC Tools" available on both "Play Store" (Android) and "App Store" (iPhone) and the app for Android was able to read ATQA and SAK while the version for iPhone was not capable of doing it.
    So for this reason I guess there might be some sort of limitation/restriction right now in iOS 13 to read these tags or am I doing something wrong?.
    Here below you can find the steps I implemented in my app, to interact with a MIFARE card in iOS 13:

    1) Instantiated a "NFCTagReaderSession" variable, with an option compatible to discover MiFare tags:

    mySession = NFCTagReaderSession(pollingOption: .iso14443, delegate: self) 
    mySession?.alertMessage = "Hold your iPhone near the MIFARE tag to learn more about it."
    mySession?.begin()


    2) When the tag is discovered the delegate method "tagReaderSession(_ session: NFCTagReaderSession, didDetect tags: [NFCTag])" gets called:

    @available(iOS 13.0, *)
    func tagReaderSession(_ session: NFCTagReaderSession, didDetect tags: [NFCTag]) {

    guard let firstTag = tags.first else { return }

    // MiFare tag
    if case let NFCTag.miFare(tag) = firstTag {
    print("MIFARE Family: \(tag.mifareFamily.title)")
    print("MIFARE identifier HEX: \(tag.identifier.toHexString())")
    print("MIFARE historical bytes: \(tag.historicalBytes?.toHexString())")
    }

    session.connect(to: firstTag) { (error: Error?) in
    if nil != error {
    session.alertMessage = "Unable to connect to tag."
    session.invalidate()
    return
    }
    }

    //........ADPU COMMANDS IMPLEMENTATION TO READ BINARY..........
    }



    Any suggestions or help would be greatly appreciated!

    + 0  |  - 0

    Re: MiFare and iOS 13 – SAK and ATQA reading

    16. March 2020 at 14:19
    Hi Luigi

    Before iOS13, the NFC interface was very restricted and limited to NDEF compliant tags only. With iOS13, it was opened a little bit. I highly recommend not to use iOS phones for your NFC business. If you want to go this way, I would first test my software on an Android device and then try to migrate it to the iOS. If an issue occurs, you know it is not your software, it is the limitation of the device.

    The TapLinx team

    + 0  |  - 1

    Re: MiFare and iOS 13 – SAK and ATQA reading

    14. May 2020 at 14:51
    TapLinx Support, thanks for explanation.
    + 0  |  - 0
Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.