-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to parse NDefRecord from record byte array. #15
Comments
Hi @dberroa |
@acaliaro I don't have a sample that I can readily share as I went pretty deep in my integration that is tied to my code. I can copy and paste what I did for iOS and Android though that directly relates to this library. For iOS when you use CoreNFC to perform a scan it calls back to DidDetect with an iOS class NFCNdefMessage passed in. If you get one of these records you can make your NdefRecord from this library from that. In the code below messages is the NFCNdefMessage[] messages from the delegate public void DidDetect(NFCNdefReaderSession session, NFCNdefMessage[] messages)
For android I'm a little rusty with. I don't remember how exactly I get to the code below but I believe a function gets called when the tag is scanned and in this function I have an Android.Nfc.Tag that is passed in. The custom function I made is called public void ReadNFCScan(object tagInformation = null) with the tagInformation as an object but you could have casted it before hand to a Tag. `//Get the scanned tag as an NDEF Message.
So at this point with both examples I had a NdefMessage that was from this library and I was able to read it to get the information I want. I personally only needed the string content of the tag so I wrote the below function but this part you would need to handle however you are doing whatever it is you are coding: `/// /// Takes in an ndef message and gets the content we want from it. /// /// The ndef record containing the content of an NFC tag. /// The string of the message. public static String ProcessNFCRecord(NdefRecord record) { //Define the tag content we want to return. String tagContent = null;
Hope that helps. |
I'm using this library for a Xamarin Forms project that supports iOS, Android, and UWP. I am using CoreNFC on iOS to read an NDEF tag. CoreNFC only gives me the bytes of an individual record.
For this library, I only see the ability to create an NDefMessage from a byte array and then loop through that to get the payloads. I have a record payload in byte form but don't see a way to init just a single record to get it's contents.
How can I get the contents from a NDEF Record byte array?
The text was updated successfully, but these errors were encountered: