locked
[NFC/NDEF] message.dataAsString is empty

    Question

  • I have a bunch of NFC tags with NDEF text messages contained in them. The tags can be read fine by android devices and the NFC TagWriter app in the windows 8 store. 

    My problem is that I cannot read them in my app. Here is the relevant piece of code. 

    proximityDevice.subscribeForMessage("NDEF:wkt.T", messageReceived);
    
    ...
    
    function messageReceived(device, message) {
      lastTagRead = message.dataAsString;
    }

    The code goes to messageReceived just fine, the problem is that message.dataAsString is always an empty string. The tag is UTF-8 encoded and only contains a simple text string.

    Moreover on the debubber, the message.data.length and message.data.capacity properties have length equal to string stored in the tag. It seems that the problem is that the tag cannot be properly decoded. What do I do? Is there a way for me to get the raw data stored in the tag apart from using subscribeForMessage? I've looked in the documentation and that is all I found. 

    Thanks

    Saturday, June 08, 2013 5:35 AM