capawesome-team / capacitor-nfc

⚡️ Capacitor plugin for reading and writing NFC tags.
https://capawesome.io/plugins/nfc/
MIT License
73 stars 14 forks source link

bug: Unable to write to tag ISO 7816/14443 #33

Closed danielcowleypnp closed 1 year ago

danielcowleypnp commented 1 year ago

Plugin version: 5.0.2

Platform(s): iOS/Android

Current behavior: When writing with both iOS and Android it is returning the following errors: iOS: Tag is not connected Android(First write is fine any subsequent writes give this error): An unknown error has occurred.

Expected behavior: It should be writing the NDEF text record I am sending to the device. The devices i am using to test with do return a record after the write which the phonegap-nfc plugin before switching to this plugin one did return the following is an example of the text record been written and the expected result based on the phonegap-nfc plugins previous functionality

LOGIN 123\nSRION YES\nMAKERSET

which would result in the following response from the tag

LOGIN OK\nSRION OK\nMAKERSET OK

Steps to reproduce: I Get the errors from just using the sample code from the readme i just scan the tag after initiating a session

Related code:

async write(): Promise<void> {
        return new Promise((resolve) => {
            Nfc.addListener('nfcTagScanned', async (event) => {
                await Nfc.write({ 
                      message: {
                          records: [
                              this.nfc.nfcUtils.createNdefTextRecord({ 
                                  text: 'LOGIN 123\nSRION YES\nMAKERSET'
                               }).record
                          ]
                      }
                });
                await Nfc.stopScanSession();
                resolve();
            });

            Nfc.startScanSession();
        });
}

Other information: the tags i am using are ISO7816/ISO14443 following the NFC Forum Type 4 specification with the communication protocols: ISO/IEC 1443 Type A NFC Data Exchange Format - NDEF (Record type TEXT)

Capacitor doctor:

💊   Capacitor Doctor  💊 

Latest Dependencies:

  @capacitor/cli: 5.5.0
  @capacitor/core: 5.5.0
  @capacitor/android: 5.5.0
  @capacitor/ios: 5.5.0

Installed Dependencies:

  @capacitor/cli: 5.4.1
  @capacitor/android: 5.4.1
  @capacitor/ios: 5.4.1
  @capacitor/core: 5.4.1

[success] iOS looking great! 👌
[success] Android looking great! 👌
robingenz commented 1 year ago

Hey @danielcowleypnp, thank you for your request. Can you reproduce the issue with this demo app?

danielcowleypnp commented 1 year ago

Thank you for the reply @robingenz after testing with the demo app it does work as expected. Which suggests this isn't an issue with the plugin rather my app code which is vanilla javascript using the methods provided by the documentation.

robingenz commented 1 year ago

Alright, in this case i am closing this issue. However, I would still like to help you troubleshoot. Feel free to provide a Minimal, Reproducible Example using this template in a public GitHub repository so I can take a closer look.