EddyVerbruggen / nativescript-nfc

:pencil: NativeScript plugin to discover, read, and write NFC tags
MIT License
84 stars 37 forks source link

Cannot detect tag - no response #14

Closed mm-ns closed 6 years ago

mm-ns commented 6 years ago

Hi there,

I used the plugin in a sample demo app i have. However, i cannot get any response from either 2 methods:

public doStartNdefListener() { this.nfc.setOnNdefDiscoveredListener((data: NfcNdefData) => { if (data.message) { let tagMessages = []; // data.message is an array of records, so: data.message.forEach(record => { console.log("Read record: " + JSON.stringify(record)); tagMessages.push(record.payloadAsString); }); this.set("lastNdefDiscovered", "Read: " + tagMessages.join(", ")); } }, { stopAfterFirstRead: true, scanHint: "Scan a tag, baby!" }) .then(() => this.set("lastNdefDiscovered", "Listening...")) .catch(err => alert(err)); }

public doStartTagListener() { let that = this; this.nfc.setOnTagDiscoveredListener((data: NfcTagData) => { console.log("Tag discovered! " + data.id); that.set("lastTagDiscovered", data.id); }).then(() => { console.log("OnTagDiscovered Listener set"); }, (err) => { console.log(err); }); }

I verified with an app called NFC tools, the tag info were read instanteneously. Any idea?

mm-ns commented 6 years ago

Fixed. It was that my tag had to be written specifically with a specific encapsulation --> https://github.com/pokusew/nfc-pcsc/issues/30