Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NFC Write to Multiple Tags #14

Open
EngageCT opened this issue Aug 23, 2024 · 0 comments
Open

NFC Write to Multiple Tags #14

EngageCT opened this issue Aug 23, 2024 · 0 comments

Comments

@EngageCT
Copy link

Hi guys l need your assistance please. I have NFC reading and writing on my app. The reading is fine it's the writing part that is an issue. If l write to lets say 20 tags the tags are written fine from 1 to 12 tags and after that the tag writing seems to stop writing and write the same tag number like cache or the buffer issue. Every time l write the tags l have to close the app completely and open it to do the writing again. Is there something wrong or please point me in the right direction. Reading works fine you can read as many as you can writing is the one that's like the cache/buffer is building up. Your assistance will be much appreciated.

The writing should be smooth regardless of the number of tags you write to.

Any assistance or pointing me in the right direction will be much appreciated.

Writing Function Code below
writeTag(tagData) {
this.writeDate = moment().format('DD-MM-YYYY HH:mm:ss');
this.tag = tagData?.item;
console.log(this.tag);
this.platform.ready().then(() => {
this.writingTag = true;
this.listener = this.nfc.addNdefListener((res: any) => {
console.log('Listener is Active: ' + res);
}, (error) => {
this.presentToast(error);
}).subscribe(() => {
const referenceNumber = this.ndef.textRecord(this.tag?.reference_number);
const date = this.ndef.textRecord(this.writeDate);

this.nfc.write([referenceNumber, date]).then(success => {
  alert(JSON.stringify(success));
  if (success === 'OK') {
    this.listener.unsubscribe();
    this.presentToast('Successfully written to RFID Tag!');
  } else {
    this.presentToast('Could not write to tag sucessfully!');
  }
}).catch(error => {
    if (error === null) {
      this.presentToast('Tag could not be written!');
    }
    if (error === 'Only one Tag Technology can be connected at a time.') {
      this.presentToast('Failed to write to tag sucessfully, please try again!');
    }
  });

}, err => {
this.presentToast(JSON.stringify(err));
});
});
}

My environment information
Ionic:

Ionic CLI : 6.20.1 (C:\Users\Tigere Bervin\AppData\Roaming\npm\node_modules@ionic\cli)
Ionic Framework : @ionic/angular 6.7.5
@angular-devkit/build-angular : 13.0.4
@angular-devkit/schematics : 13.0.4
@angular/cli : 13.0.4
@ionic/angular-toolkit : 5.0.3

Cordova:

Cordova CLI : 11.0.0
Cordova Platforms : android 12.0.1
Cordova Plugins : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 5.0.0, (and 14 other plugins)

Utility:

cordova-res : 0.15.4
native-run (update available: 1.7.3) : 1.7.2

System:

Android SDK Tools : 26.1.1 (C:\Users\Tigere Bervin\AppData\Local\Android\Sdk)
NodeJS : v16.14.0 (C:\Program Files\nodejs\node.exe)
npm : 8.3.1
OS : Windows 10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant