chariotsolutions / phonegap-nfc

PhoneGap NFC Plugin
MIT License
706 stars 559 forks source link

cann't trigger the callback function ,and the addNdefListener return success. #162

Closed olivelihui closed 9 years ago

olivelihui commented 9 years ago

nfc.addNdefListener( writeTag, function() { alert("Success."); }, function() { alert("Fail."); } );

function writeTag(nfcEvent) { alert("write message!"); }

don commented 9 years ago

@olivelihui I'm assuming you're running on Android? addNdefListener will only trigger a callback if you scan a NFC tag with an NDEF message. If your NFC tag is not NDEF or hasn't been formatted you'll need to use addTagDiscoveredListener or addNdefFormatableListener.

Also, if you have a phone with the Broadcom NFC chipset it won't be able to read Mifare Classic NFC tags even if they are NDEF formatted.

Try using another app like NFC TagInfo by NXP to determine what's on your NFC tags. You can use NFC TagWriter by NXP to format and write messages to tags.

don commented 9 years ago

Assuming you've fixed this by adding additional listeners. If not, reopen the issue.