I created an app using CoreNFC to read NFC tags, I managed to get the app run without any errors, but it doesn't seem to recognise my tags, I've tried it with two tags of same type and brand which I got it from Amazon for few a bucks, and I tried my local train card(NFC Card) which has no effect too... What might be the problem? I've attached the screenshot of the app, please take a look! Screenshot of my App, nothing happens beyond this point, and nothing on the console too.
Thanks,
Hari
func readerSession(_ session: NFCNDEFReaderSession, didInvalidateWithError error: Error) {
print("ERROR")
}
func readerSession(_ session: NFCNDEFReaderSession, didDetectNDEFs messages: [NFCNDEFMessage]) {
print(messages)
}
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
let session = NFCNDEFReaderSession(delegate: self as NFCNDEFReaderSessionDelegate, queue: nil, invalidateAfterFirstRead: false)
session.begin()
return true
}
At the moment, CoreNFC only supports NFC tags in NDEF format. Therefore, most of your NFC cards (credit card, id card, members cards, etc.) won't work as they most probably do not comply to this format. If you want to test CoreNFC you need to use dedicated NDEF tags.
From the CoreNFC documentation:
Using Core NFC, you can read Near Field Communication (NFC) tags of types 1 through 5 that contain data in the NFC Data Exchange Format (NDEF).