Page 1 of 1

NFC Tag Read - LC 9

Posted: Tue May 08, 2018 8:30 pm
by Googie85
I have the following code, but receive nothing in the pTag variable. Any ideas as to why?

Code: Select all

on openStack
   if mobileIsNFCEnabled() is "true" then 
      answer "Device NFC has been turned on"
      mobileEnableNFCDispatch
      
   else
      answer "NFC not available. Please switch it on."
      break
   end if
   
   if mobileIsNFCAvailable() is "true" then 
      answer "NFC tags can be read"
   end if
end openStack

on nfcTagReceived pTag
      answer pTag
end nfcTagReceived


Many Thanks,

Googie.

Re: NFC Tag Read - LC 9

Posted: Wed May 09, 2018 10:05 pm
by jacque
The pTag parameter is an array, so it can't be represented by a text string such as "answer" requires. You'll need to access each element using array notation. For example:

Code: Select all

on nfcTagReceived pTag
   put pTag["id"] into tID
   put pTag["ndef"]["payload"] into tData
end nfcTagReceived