semlette / nfc_in_flutter

Cross-platform flutter plugin for reading and writing NFC tags. Not maintained anymore - not looking for new maintainer, fork instead.
MIT License
120 stars 119 forks source link

Cannot get data only (payload includes the path) #11

Closed laudaget closed 4 years ago

laudaget commented 5 years ago

Is there a way to get the data without the path provided in payload? Couldn't figure out a way to cut away the path.

The content on my nfc chips are like 100001, 100002, 100003.. I would like to get '1000001' as my response, but the payload gives me '�en100001' instead.

Thank you in advance

semlette commented 5 years ago

Quite frankly I don't know. If you write the payload with a custom mime type, the payload should be normal. It's only on "well known" types and the like where it does this.

laudaget commented 5 years ago

Thank you for your answer.

I've tried several Apps from the playstore to write on the tags. Each app gives a diffrent prefix to my content if i read it out with your flutter plugin. But when i use other apps to read out the content, there is no prefix and i get the expectet output '100001'.

If it helps, my tag has the following specs:

you can find more about my tag: https://www.nfc-tag-shop.de/en/nfc-sticker/black-white-nfc-tags/103/nfc-sticker-pvc-on-metal-30-mm-ntag-213-180-byte-white?number=68236

semlette commented 5 years ago

Right, I've got some code brewing and I may be able to remove it. I'll release a test version with the changes soon.

semlette commented 5 years ago

Could you try again using the payload-data branch?

laudaget commented 5 years ago

First of all, i really appreciate your efforts and time you put into this.

With the payload-data branch i was able to get the expectet output with message.records.first.data.

Because i am curious i would like to know what the prefix was. Was it the path or a variable to find the data?

Thank you very much.

semlette commented 5 years ago

After some reading I found out that it is part of the NDEF specification. Tags encoded with a "well known type" of "text", will have their (usually) first two characters be the language code of the text. By doing some magic, you can get the length of the language code and then remove it.

semlette commented 4 years ago

Closing this as I have (finally) released version 2.0.0, which adds the .data property for both iOS and Android.