Page 1 of 1

Try to read a NFC tag with my Android phone

Posted: Wed Oct 11, 2017 10:14 am
by Peter@multidesk.se
I don't get "nfcTagReceived" to work?
My phone beeps but the message does not seem to be trapped by livecode.

Does anyone else experienced this problem?

///Peter

Re: Try to read a NFC tag with my Android phone

Posted: Wed Oct 11, 2017 11:58 am
by Peter@multidesk.se
Ok, now I am confused...

After some testing I found out that "mobileEnableNFCDispatch" doesn't work as well...

This whole NFC thing dosen't seem to work at all... Is there anyone that has got this to actually work?


///Peter

Re: Try to read a NFC tag with my Android phone

Posted: Wed Oct 11, 2017 2:02 pm
by Mikey
have you emailed jacque, yet? She paid to have the external written.

Re: Try to read a NFC tag with my Android phone

Posted: Wed Oct 11, 2017 5:55 pm
by jacque
No need to email, I'm here. :) I've been using NFC in a commercial project and it works very well. The sample scripts in the dictionary are correct and are the basis of my scripts.

You must enable NFC before use and disable it when the stack closes. I assume you're doing that.

Not all Android devices support NFC so make sure yours does. Every manufacturer puts the reader in a different place so you need to know exactly where to tap for your device. On my Android tablet the hot spot is in the center of the back panel. On my Samsung phones it's about a 2/3 of the way down. On my pixel it's somewhere in between. Android will beep when it senses a signal. There are two different beep sounds, one for a successful read and another for an unsuccessful one. If the read fails, the app won't get any notifications.

Download NFC Tools from Android Play and practice with that to see how your phone behaves.

Re: Try to read a NFC tag with my Android phone

Posted: Wed Oct 11, 2017 6:43 pm
by Peter@multidesk.se
Jacque,

I've done all that and the phone works with an NFC app from Google play.

this is what I tried:


on preOpenCard
    if the environment is "mobile"
    then
       if mobileIsNFCAvailable () is "true" then answer "NFC tags can be read" ## This works fine
     
       if mobileIsNFCEnabled () is "true" then answer "Device NFC has been turned on" ## This works fine
      
       if mobileIsNFCEnabled () is "false" then answer "Device NFC has been turned off" ## This works fine
    end if
end preOpenCard



on openCard
    if the environment is "mobile"
    then
       mobileEnableNFCDispatch ## does not seem to work because the NFC app from google play opens ...
    end if
end openCard

on closeCard
    if the environment is "mobile"
    then
       mobileDisableNFCDispatch
    end if
end closeCard

on nfcTagReceived ncfTag
    answer "Reading Ok!" ## Nothing happens, not executed.
end nfcTagReceived



///Peter

Re: Try to read a NFC tag with my Android phone

Posted: Wed Oct 11, 2017 8:13 pm
by jacque
Oh, I know what's wrong. You need to include the NFC extension in the standalone settings. When I first started using it, there was no such thing in the extensions list so I had to add it manually. I just checked the list in LC 9.x and I see they still haven't added it, so there would be no way you'd know about it.

In the message box, do this:

Code: Select all

set the cRevStandaloneSettings["android,nfc"] of stack "myStack" to true
Then do a new build. I'll submit a bug report, that extension really needs to be available and visible.

Re: Try to read a NFC tag with my Android phone

Posted: Wed Oct 11, 2017 8:22 pm
by jacque