Hi all,
I’m am using Ionic v4 and Capacitor. I am attempting to use https://github.com/chariotsolutions/phonegap-nfc to read and write NDEF tags (https://www.amazon.com/dp/B075CFXY8V/ref=cm_sw_em_r_mt_dp_U_APeBDbM9T41J6)
I’ve installed the plugin as per instructions for using Cordova plugins with Capacitor, and the plugin itself seems fine. I have no problem getting information from tags. There is also seems to be a problem with Android Beam being on / off?
Upon trying to write to the tag when Android Beam is off, however, I get the following messages:
2019-09-01 18:51:50.563 4104-4244/io.ionic.starter V/Capacitor: callback: -1, pluginId: Console, methodName: log, methodData: {"level":"log","message":"NDEF_PUSH_DISABLED"}
2019-09-01 18:51:50.564 4104-4195/io.ionic.starter I/Capacitor/Plugin/Console: NDEF_PUSH_DISABLED
Upon trying to write to the tag when Android Beam is on, I get the following and nothing gets written:
2019-09-01 18:55:11.834 2987-7628/? D/SecContentProvider: query(), uri = 15 selection = isAndroidBeamAllowed
2019-09-01 18:55:11.835 2987-7628/? D/SecContentProvider: called from io.ionic.starter
2019-09-01 18:55:11.835 2987-7628/? D/RestrictionPolicy: isAndroidBeamAllowed : true
2019-09-01 18:55:11.837 4790-4790/io.ionic.starter E/NFC: isAndroidBeamAllowed - Begin
2019-09-01 18:55:11.837 4790-4790/io.ionic.starter I/NFC: showMsg is false
Here is the code I am using to write data:
writeNfc(data: any) {
this.scanning = true;
this.presentToast('Setting up...');
this.nfc
.addNdefListener(
() => {
this.presentToast('Successfully connected NDEF listener');
},
err => {
this.presentToast(
'There was an error connecting to an NDEF listener. Make sure you have NFC turned on.'
);
}
)
.subscribe(event => {
const message = this.ndef.textRecord('test');
this.nfc
.share([message])
.then(success => {
console.log(success);
this.presentToast('Successfully written!');
this.scanning = false;
})
.catch(error => {
this.scanning = false;
this.presentToast('Writing failed. Please try again.');
console.log(error);
});
});
}
and thus writing is unsuccessful. The permissions are granted, NFC is on, and everything seems fine in the config. Has anyone else ran into / solved this problem? Does have anything to do with Android Beam being on / off? Thanks!