Post not yet marked as solved
Post marked as unsolved with 1 replies, 983 views
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()
}
}