How to formate NFC tags to NDEF format?


I was using NFCNDEFReaderSessionDelegate at first to read and write the cards, but didDetect tags method did not detect any tag because my nfc tag is not pre-formatted. Hence, I used NFCTagReaderSessionDelegate, didDetect tags method of NFCTagReaderSessionDelegate detected tag eventhogh tag was not pre-formatted. The issue I have been facing is I am not able to write for the first time and getting an error Error Domain=NFCError Code=102 "Tag Not NDEF formatted" UserInfo={NSLocalizedDescription=Tag Not NDEF formatted}. When I used another apple store app to write data on the same tag which is not pre-formatted. Using that app, I am able to write the data on that tag. I am not sure how can I fix this issue. Please provide some sample code to make the tag ready to have NDEF format and able to write the data on it.

Here is my NFC tag details:


Hi. This forum is for discussion of the Swift Language itself. Your question is about an Apple closed-source framework. It’s better to ask those kinds of questions on Apple’s Developer Forums, or Stack Overflow.