Wednesday, September 28, 2022
HomeiOS Developmentios - CoreNFC - Empty NDEF after improve to iOS16

ios – CoreNFC – Empty NDEF after improve to iOS16


I’ve simply up to date to iOS 16, and rapidly the identical code I utilized in iOS 15 is now studying ndefMessage as nil within the didDetect callback. I am unable to discover something on-line relating to what in iOS 16 would trigger this, has anybody seen something comparable?

Once I scan the identical tag on Android, or use the NFC Instruments app on iOS, I can learn the tag NDEF wonderful. Plainly simply my code appears to have been affected by the replace…

This is what I’ve:

func readerSession(_ session: NFCNDEFReaderSession, didDetect tags: [NFCNDEFTag]) {
    print("did detect")
    let str: String = nfcWriteContent
    if (tags.depend > 1) {
        let retryInterval = DispatchTimeInterval.milliseconds(500)
        session.alertMessage = "too_many_nfc_detected".localized()
        DispatchQueue.world().asyncAfter(deadline: .now() + retryInterval, execute: {
            session.restartPolling()
        })
        return
    }
    
    let tag = tags.first!
    
    print("studying...")
    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, NDEF CONTENT IS PROPERLY RETURNED
            print("empty tag")
        } else {
            print (ndefMessage!.information.depend)
            for payload in ndefMessage!.information {
                if (payload.payload.depend == 0) {
                    proceed
                }
                res += (String.init(knowledge: payload.payload.superior(by: 1), encoding: .utf8) ?? "Format not supported")
            }
        }
        
        session.alertMessage = "tag_successfully_read".localized()
        session.invalidate()
        print("learn (res)")
    })
            
}

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments