i have a very fundamental issue when reading from a rfid chip using ios 13+ and swift 5, i have two setups (NFCNDEFReaderSession and NFCTagReaderSession),
NFCNDEFReaderSession:
import UIKit
import CoreNFC
class ViewController: UIViewController {
var session: NFCNDEFReaderSession?
override func viewDidLoad() {
super.viewDidLoad()
session = NFCNDEFReaderSession(delegate: self, queue: DispatchQueue.main, invalidateAfterFirstRead: false)
session?.begin()
}
}
extension ViewController: NFCNDEFReaderSessionDelegate {
func readerSessionDidBecomeActive(_ session: NFCNDEFReaderSession) {
print("active") // called once
}
func readerSession(_ session: NFCNDEFReaderSession, didDetectNDEFs messages: [NFCNDEFMessage]) {
print("didDetectNDEFs") // never called
}
func readerSession(_ session: NFCNDEFReaderSession, didInvalidateWithError error: Error) {
print(error.localizedDescription) // only called on timeout
}
}
NFCTagReaderSession:
import UIKit
import CoreNFC
class ViewController: UIViewController {
var session: NFCTagReaderSession?
override func viewDidLoad() {
super.viewDidLoad()
session = NFCTagReaderSession(pollingOption: NFCTagReaderSession.PollingOption.iso14443, delegate: self, queue: DispatchQueue.main)
session?.begin()
}
}
extension ViewController: NFCTagReaderSessionDelegate {
public func tagReaderSessionDidBecomeActive(_ session: NFCTagReaderSession) {
print("active") // called once
}
public func tagReaderSession(_ session: NFCTagReaderSession, didDetect tags: [NFCTag]) {
print("didDetect") // never called
}
public func tagReaderSession(_ session: NFCTagReaderSession, didInvalidateWithError error: Error) {
print(error.localizedDescription) // only called on timeout
}
}
My hardware (NEW):
YARONGTECH Rfid chip 13.56 mhz MIFARE Classic® 1K tag - 10pcs
from amazon:
In both scenarios the "didDetectNDEFs" and the "didDetect" methods never get called.
I went through apple documentation: https://developer.apple.com/documentation/corenfc and they actually claim it is possible(A reader session for detecting ISO7816, ISO15693, FeliCa, and MIFARE tags.), but how?..
This guy also claims he could read from these rfid chips: Detect ISO/IEC 14443 (Mifare Ultralight or Classic) NFC Cards with CoreNFC
Please respond only if you know the answer