NFC Tag Read - LC 9

The place to discuss anything and everything about running your LiveCode on Android

Moderators: heatherlaine, Klaus, FourthWorld, robinmiller, kevinmiller

Post Reply
Posts: 93
Joined: Tue Aug 05, 2014 10:07 am

NFC Tag Read - LC 9

Post by Googie85 » Tue May 08, 2018 8:30 pm

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"
      answer "NFC not available. Please switch it on."
   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,


VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4454
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN

Re: NFC Tag Read - LC 9

Post by jacque » Wed May 09, 2018 10:05 pm

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
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software |

Post Reply

Return to “Android Deployment”