UID NFC tags

Hi, im developing an app for read NFC tags but now only i can read message payload, i want to know if i would read UID or other features from the nfctag.


Regards

Bump because having the same issue -- trying to access the UID from NFCTag.miFare(tag) after creating an instance of NFCNDEFReaderSession or NFCTagReaderSession. Identifier value is always empty.


FIgured it out:


Inside your:

func tagReaderSession(_ session: NFCTagReaderSession, didDetect tags: [NFCTag]) {

Add:

  if case let NFCTag.miFare(tag) = tags.first! {
  session.connect(to: tags.first!) { (error: Error?) in
  let tagUIDData = tag.identifier
  var byteData: [UInt8] = []
  tagUIDData.withUnsafeBytes { byteData.append(contentsOf: $0) }
  var uidString = ""
  for byte in byteData {
  let decimalNumber = String(byte, radix: 16)
  if (Int(decimalNumber) ?? 0) < 16 { // add leading zero
  uidString.append("0\(decimalNumber)")
  } else {
  uidString.append(decimalNumber)
  }
  }
  debugPrint("\(byteData) converted to Tag UID: \(uidString)")
  }
  }

I am able to connect to the card using NFCTagReaderSession and NFCISO7816Tag tag but i can't get ATR number after connection and it shows zero bytes in historicalBytes, while in android we are able to get some number in historicalBytes for same type of cards\


One more filed we have NFCISO7816Tag "identifier" but it is getting different number for same type of card.


print("iso7816Tag historical bytes \(iso7816Tag.historicalBytes)")

print("iso7816Tag identifier \(iso7816Tag.identifier)")


We want same number or value for same type of card that can be used for ATR validation in our code.


Please suggest to get an ATR number or value for same type of cards.

UID NFC tags
 
 
Q