Corenfc Not Reading Uid in iOS

how to get icManufacturerCode of NFC tag in iOS

The issue for iOS11 are related to the signature of classes and protocols on the part of Apple (protocol NFCTag have become enum for iOS13, if I don't confuse). However, you can use this code and it should work for all versions of iOS11+

extension YourViewController: __NFCReaderSessionDelegate {

func readerSessionDidBecomeActive(_ session: NFCReaderSession) {

}

func readerSession(_ session: NFCReaderSession, didInvalidateWithError error: Error) {

}

func readerSession(_ session: NFCReaderSession, didDetect tags: [__NFCTag]) {
for tag in tags {
let rfidTag = tag as! NFCISO15693Tag
print("- Is available: \(rfidTag.isAvailable)")
print("- Type: \(rfidTag.type)")
print("- IC Manufacturer Code: \(rfidTag.icManufacturerCode)")
print("- IC Serial Number: \(rfidTag.icSerialNumber)")
print("- Identifier: \(rfidTag.identifier)")
}
}
}

There are 2 required methods and one optional (it's from Obj-C), just to get icManufacturerCode.

According to documentation of Apple

use an instance of NFCNDEFReaderSession or NFCTagReaderSession. Only
one reader session of any type can be active in the system at a time

CoreNFC - Empty NDEF after upgrade to iOS16

I got feedback from an Apple engineer. The sample project runs fine on iOS 16. You are missing out that you are not connected to the tag:

try await ndefReaderSession?.connect(to: tag)
let message = try await tag.readNDEF()

or

ndefReaderSession?.connect(to: tag) { error in
//call tag.readNDEF here
}

iOS 11 CoreNFC How To Check if device has NFC Capability?

You can use the readingAvailable class property:

if NFCNDEFReaderSession.readingAvailable {
// Set up the NFC session
} else {
// Provide fallback option
}


Related Topics



Leave a reply



Submit