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
Wait for Async Task to Finish Completion Block Before Returning in App Delegate
Uiactivityviewcontroller - Email and Twitter Sharing
Afnetworking 2.0 Track File Upload Progress
Cagradientlayer Diagonal Gradient
Uitableviewcell with Uiwebview Dynamic Height
Where Are iOS Simulator Screenshots Stored
How to Change the Uisearchbar Search Text Color
How to Find a Specification in Cocoapods
iOS App Crashing Every Other Launch, Can't Find Error
How to Add Constraint Between a View and the Top Layout Guide in a Xib File
How to Write Init Methods of a Uiviewcontroller in Swift
How to Change Navigation Bar Color in iOS 7 or 6
Uiscrollview's Origin Changes After Popping Back to the Uiviewcontroller
Improper Advertising Identifier [Idfa] Usage