chariotsolutions / phonegap-nfc

PhoneGap NFC Plugin
MIT License
706 stars 556 forks source link

addTagDiscoveredListener fired twice a moment #308

Closed juristamrcl closed 6 years ago

juristamrcl commented 6 years ago

I use reading NFC cards for sending HTTP requests. Sometimes, the addTagDiscoveredListener is fired twice at the same moment. I tryied to add the if statement immediately after firing this event, which should block doing the method, if another addTagDiscoveredListener event is fired within 1 second. But nor will it set the variable, another addTagDiscoveredListener is fired and my request is sent twice. It is also difficult to handle it in database, as it is sent almost at the same time. Using Lenovo TAB3 10 PLUS.

KantaP commented 6 years ago

me too

don commented 6 years ago

Some devices aggressively read tags. I think it's up to the app or database to handle the duplicate reads. This isn't easy to stop in Android or the plugin.

One way to handle this would be to have your event handler ignore all reads for 2 seconds after a successful read.