Reading UIDs of NFC Cards in iOS 13

后端 未结 3 1777
一整个雨季
一整个雨季 2020-12-16 19:47

I would like to retrive the UID of MiFare cards. I\'m using an iPhone X, Xcode 11 and iOS 13.

I\'m aware this wasn\'t possible (specifically reading the UID) until

3条回答
  •  情歌与酒
    2020-12-16 20:29

    I know you have said that it returns nil but for clarity for future readers:

    Assuming it is not a Felica tag, it should be on the identifier field when it is detected:

    func tagReaderSession(_ session: NFCTagReaderSession, didDetect tags: [NFCTag]) {      
      if case let NFCTag.miFare(tag) = tags.first! {
        print(tag.identifier as NSData)
      }
    }
    

    But in your case, it's empty (see edit below). For most tags the APDU to get the UID of a tag is

      0xff // Class
      0xca // INS
      0x00 // P1
      0x00 // P2
      0x00 // Le
    

    so you could try using tag.sendMiFareCommand to send that command manually.

    Edit: Response from OP, it wasn't empty but was unclear because printing Data in Swift doesn't show in console

提交回复
热议问题