如何解决ionic5 - nfc,无法提取有效载荷数据
我正在使用 https://ionicframework.com/docs/native/nfc 中的 pligin,代码如下:
import { Component } from '@angular/core';
import { NFC,Ndef } from '@ionic-native/nfc/ngx';
import { NavController,Platform,AlertController,ToastController } from '@ionic/angular';
@Component({
selector: 'app-home',templateUrl: 'home.page.html',styleUrls: ['home.page.scss'],})
export class HomePage {
constructor(public platform: Platform,private alertCtrl: AlertController,private toastCtrl: ToastController,public navCtrl: NavController,private nfc: NFC,private ndef: Ndef) { }
ngOnInit() {
this.addListenNFC();
}
async addListenNFC() {
this.nfc.addTagDiscoveredListener(nfcEvent => this.sesReadNFC(nfcEvent)).subscribe(data => {
alert(JSON.stringify(data.tag));
console.log(JSON.stringify(data));
if (data && data.tag && data.tag.id) {
let tagId = this.nfc.bytesToHexString(data.tag.id);
alert('ID: ' + JSON.stringify(tagId));
}
});
}
async sesReadNFC(data) {
alert('NFC_WORKING' + JSON.stringify(data));
console.log(JSON.stringify(data));
}
}
然而,我唯一能够读取的数据是
{"isTrusted":false,"tag":{"id":[8,13,-23,89],"techTypes":
["android.nfc.tech.IsoDep","android.nfc.tech.NfcA"]}}
我正在尝试从护照中读取数据。我在 Play Store 上用其他应用测试过,它能够读取所有个人数据,甚至可以提取照片。
知道我的代码中可能缺少什么吗?
谢谢!
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。