Using CoreNFC I want to read icMenufecturerCode of NFC Tag. According to Apple documentation NFCISO15693Tag has property named icManufacturerCode that can be read as:
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)")
}
}
But I am getting confused .. is it the right tag reader session or there is some other way to read manufacturer Id of NFC Tag in iOS 11.
In iOS 11 we have NFCNDEFReaderSession
. I implemented code using NFCNDEFReaderSessionDelegate
but those methods doesn't provide any way to read icManufacturerCode. Is it fine to replace that code with NFCReaderSessionDelegate
methods??
And what type of tag will NFCReaderSession
read?
I know it is not a good and clear question but my confusion is something weird. Thanks.
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