chariotsolutions / phonegap-nfc

PhoneGap NFC Plugin
MIT License
706 stars 557 forks source link

addTagDiscoveredListener is not working after addNdefListener is being registered #237

Closed Swathi8 closed 8 years ago

Swathi8 commented 8 years ago

Hi,

I'm using addTagDiscoveredListener and addNdefListener methods to discover is any nfc tag found(if so, write ndefMessage to tag) and read data from nfc tag respectively. At any point of time only one of the method will be registered based on some condition.

I'm using Backbone in front-end. when view renders, registering any one of these methods based some condition and removing listeners on destroy of the view.

Once addNdefListener is registered and remove it on view destroy. And registering addTagDiscoveredListener method on view render is not calling callback of addTagDiscoveredListener method. Where as it works before registering the addNdefListerer.

Don't know what is happening here!, Why addTagDiscoveredListener is not working once addNdefListener method is register. Is anything I'm doing wrong?

don commented 8 years ago

Android always calls the most specific listener for any tag. If you have addTagDiscoveredListener and addNdefListerer NDEF tags always end up with addNdefListerer

I don't recommend removing listeners, I'd always keep both listeners added.