I am using this plugin NFC Scanner | PhoneGap iOS/Android/Windows NFC Reader Plugin
And following this doc GitHub - chariotsolutions/phonegap-nfc: PhoneGap NFC Plugin
Here you can see my code
import { Component, OnInit } from '@angular/core';
import { NFC, Ndef } from '@awesome-cordova-plugins/nfc/ngx';
import { Platform } from '@ionic/angular';
@Component({
selector: 'app-cardwrite',
templateUrl: './cardwrite.page.html',
styleUrls: ['./cardwrite.page.scss'],
})
export class CardwritePage implements OnInit {
ndefMsg: any;
constructor(
private nfc: NFC,
private ndef: Ndef,
private platform: Platform
) {
this.platform.ready().then(() => {
this.nfc.addNdefListener(this.scanToWrite);
});
}
scanToWrite(){
console.log("entered into scanToWrite");
this.ndefMsg = this.ndef.textRecord('I am Hasan');
this.nfc.write([this.ndefMsg]).then((writeResp) => {
console.log("writeResp: ", writeResp);
})
.catch(err => {
console.log("written error : ", err);
});
}
ngOnInit(){
}
}
I am using Android 10 based Sony Xperia ZX3.
When I run the app installed directly from android studio, In Google Chrome Console, I can see NFC initialised, when I put NFC card/tag behind NCF receptor of my phone, It makes sound but I don’t see any success or error in console log.
As you can see the code above, here you can see console log
I am tying to write simple text to the card and tags like this
The good thing is, I can read some data using the code referred to the official Ionic website documentation. Here you can see my console log of reading the cards/tags
Is there anyone who can help me to figure out how I can write text or data structure like array of objects in these cards/wristband tags?
All the available example I found online, I have tried most of them but no luck.
Any help will be highly appreciated!