我正在使用phonegap-nfc插件来读取我的科尔多瓦应用程序中的NFC标签。我还在AndroidManifest.xml中包含了uses-permission标签。 我的打字稿码是:科尔多瓦NFC插件工作,但没有引发任何事件
module myapp.nfcRead {
export class NfcCtrl {
private status:string;
constructor(private $cordovaNfc:any, private $cordovaNfcUtil:any) {
this.status = "nfc";
}
public readNFC() {
console.log("trying to find nfc");
this.$cordovaNfc.then((nfcInstance:any) => {
nfcInstance.addNdefListener((nfcEvent:any) => {
this.status = "NFC Detected";
})
.then(
//Success callback
(event:any) => {
this.status = "Reading NFC";
console.log("Reading NFC");
},
//Fail callback
(err:any) => {
this.status = "error";
console.log("error");
});
});
this.$cordovaNfcUtil.then((nfcUtil:any) => {
this.status = nfcUtil.bytesToString("some bytes");
});
}
}
NfcCtrl.$inject = ['$cordovaNfc', '$cordovaNfcUtil'];
angular.module('myapp.nfcRead', ['ngCordova.plugins.nfc']).controller('NfcCtrl', NfcCtrl);}
如果我在浏览器中启动应用程序,我调用方法“readNFC()”的状态保持为“NFC”。如果我在我的android手机上部署应用程序,并且我称之为“readNFC()”功能并且NFC被禁用,则状态为“错误”。激活NFC并再次调用该功能后,它会显示“正在读取NFC”。现在我想要读取NFC标签,但状态不会改变。 (无事件引发)
我下载了一个应用程序从谷歌Play商店,看看标签发现: (APP:NFC工具) NFC Tools output
你对我有什么提示? 谢谢
您是否找到解决方案?非常感谢 – Danilo