admin管理员组文章数量:1418088
I want to read nfc card with phonegap nfc ( Tutorial phonegap ) but the event is not launched
this is the code of the index.js
onDeviceReady: function() {
app.receivedEvent('deviceready');
// Read NDEF formatted NFC Tags
nfc.addNdefListener (
function (nfcEvent) {
var tag = nfcEvent.tag,
ndefMessage = tag.ndefMessage;
// dump the raw json of the message
// note: real code will need to decode
// the payload from each record
alert(JSON.stringify(ndefMessage));
// assuming the first record in the message has
// a payload that can be converted to a string.
alert(nfc.bytesToString(ndefMessage[0].payload).substring(3));
},
function () { // success callback
alert("Waiting for NDEF tag");
},
function (error) { // error callback
alert("Error adding NDEF listener " + JSON.stringify(error));
}
);
},
Any suggestion ?
I want to read nfc card with phonegap nfc ( Tutorial phonegap ) but the event is not launched
this is the code of the index.js
onDeviceReady: function() {
app.receivedEvent('deviceready');
// Read NDEF formatted NFC Tags
nfc.addNdefListener (
function (nfcEvent) {
var tag = nfcEvent.tag,
ndefMessage = tag.ndefMessage;
// dump the raw json of the message
// note: real code will need to decode
// the payload from each record
alert(JSON.stringify(ndefMessage));
// assuming the first record in the message has
// a payload that can be converted to a string.
alert(nfc.bytesToString(ndefMessage[0].payload).substring(3));
},
function () { // success callback
alert("Waiting for NDEF tag");
},
function (error) { // error callback
alert("Error adding NDEF listener " + JSON.stringify(error));
}
);
},
Any suggestion ?
Share Improve this question asked Mar 15, 2016 at 8:30 user40101121user40101121 1672 silver badges9 bronze badges 1- Are you trying to read with the app opened? Do you have any output in the console or alerts? – Víctor Commented Mar 15, 2016 at 8:50
1 Answer
Reset to default 5Solved with nfc.addTagDiscoveredListener instead of nfc.addNdefListener
本文标签: javascriptNFC reader apache cordovaStack Overflow
版权声明:本文标题:javascript - NFC reader apache cordova - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745241237a2649339.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论