coreNFC write NDEF with utf8

Hi,


I am trying to write NDEF-data to a nfc-tag. It works partially. I can write data to the tag. But the data is written with UTF-16 which makes it unreadable for my android app. How do I create a NFCNDEFPayload.wellKnownTypeTextPayload with utf-8 encoding.


This is how I create and write the NDEF.


//ndef creation
let textPayload = NFCNDEFPayload.wellKnownTypeTextPayload(string: tmpMessage, locale: Locale(identifier: "En"))
self.ndefMessage = NFCNDEFMessage(records: [(textPayload!)])

//write
tag.writeNDEF(self.ndefMessage!) { (error: Error?) in
                            print(error ?? "error")
                            if error != nil {
                                session.invalidate(errorMessage: "Update tag failed. Please try again.")
                            } else {
                                session.alertMessage = "Update success!"
                                session.invalidate()                                
                            }
                        }

Replies

I have the same question. Is it possible to write NDEF-data to an nfc-tag with UTF-8 (not the UTF-16 default), so it is compatible with Android and other NFC readers?