Post

Replies

Boosts

Views

Activity

CoreNFC - Empty ndefMessage when upgrading to iOS 16
After upgrading to iOS 16, the code below that I have to read the NDEF contents of an  NFC Forum Type 2 Tag now returns an empty string. When running the same code on my iOS 15 device, this code works perfectly. When downgrading my iOS 16 device to iOS 15, this code works perfectly again. I can't find any documentation regarding changes made to CoreNFC in iOS 16 that would be affecting this, can anyone shed any light here please? func readerSession(_ session: NFCNDEFReaderSession, didDetect tags: [NFCNDEFTag]) { print("did detect") let str: String = nfcWriteContent if (tags.count > 1) { let retryInterval = DispatchTimeInterval.milliseconds(500) session.alertMessage = "too_many_nfc_detected".localized() DispatchQueue.global().asyncAfter(deadline: .now() + retryInterval, execute: { session.restartPolling() }) return } let tag = tags.first! print("reading...") tag.readNDEF(completionHandler: {(ndefMessage: NFCNDEFMessage?, error: Error?) in var res = "" if (ndefMessage == nil) { // EVERY NFC SCAN ALWAYS FALLS IN HERE NOW // WHEN SCANNING THE SAME TAG ON ANDROID, AND ON IOS 15, NDEF CONTENT IS PROPERLY RETURNED print("empty tag") } else { print (ndefMessage!.records.count) for payload in ndefMessage!.records { if (payload.payload.count == 0) { continue } res += (String.init(data: payload.payload.advanced(by: 1), encoding: .utf8) ?? "Format not supported") } } session.alertMessage = "tag_successfully_read".localized() session.invalidate() print("read \(res)") }) }
1
0
1.1k
Sep ’22