chariotsolutions / phonegap-nfc

PhoneGap NFC Plugin
MIT License
706 stars 557 forks source link

Unable to call different function every time while tapping NFC card #260

Closed testaccnt0435 closed 7 years ago

testaccnt0435 commented 7 years ago

In my app, i have two ionic controllers. First login controller, when tapping NFC card , it will verify the card number and login. Second Dashboard controller, when tapping new NFC card, it will verify the card number and get value from api. But when i tap second NFC card, first controller is also called. I am using 'addTagDiscoveredListener' for read the NFC card. Help me to call different function every time while tapping NFC card. I have this code in both controllers, var nfcid = nfc.addTagDiscoveredListener(onNfc, win, fail);

don commented 7 years ago

I'd set up a NFC service to receive the data from the tags. This way you can have one function that handles the NFC read. Based on the data you get you can dispatch from the NFC service to the proper controller.