I notice that there are two types of nfc session:
- "NFCTagReaderSession" this session in order to get tag's basic info like uid/type which call back function is
tagReaderSession(_ session: NFCTagReaderSession, didDetect tags: [NFCTag])
- "NFCNDEFReaderSession" this session in order to get ndef message in tag which call back function is
readerSession(_ session: NFCNDEFReaderSession, didDetectNDEFs messages: [NFCNDEFMessage])
My problem:
How can i get tag's basic info and tag's ndef message(if it exists) simultaneously in one session or in one callback function.
You can do this by using NFCTagReaderSession
alone.
When you connect to a tag, in the callback you will get a tag of type other than NDEF, and you can then send the necessary commands to get whatever information you are after (as long as it is supported).
Several tag protocols (NFCISO7816Tag, NFCMiFareTag, NFCISO15693Tag) are supersets of NFCNDEFTag, so after you read the other data you need, you can use the readNDEF(completionHandler:)
to read the NDEF message from the tag.