capawesome-team / capacitor-plugins

⚡️ Community plugins for Capacitor. Supports Android, iOS and the Web.
https://capawesome.io/plugins/
235 stars 38 forks source link

feat: iOS NFC reading support for ISO 14443-3A NfcA tags #316

Open gordins opened 1 week ago

gordins commented 1 week ago

Plugin(s)

Current problem

The NFC reader on iOS does not scan ISO 14443-3A NfcA type tags. Those are accessible via iOS API but not exposed via the Nfc.startScanSession method.

Preferred solution

We should have an option for the startScanSession method to enrich the reading compatibility of NFC tags on iOS so that ISO 14443-3A NfcA can be supported.

Alternative options

An alternative option could be having this kind of tags scannable by default in the startScanSession, but given that this might need a older/different API, having it expose via an option might be the better alternative.

Additional context

Initial discord question

Before submitting

robingenz commented 1 day ago

Hey @gordins, thank you for creating this issue! I worked on a solution last week and just created a dev release:

npm i @capawesome-team/capacitor-nfc@6.3.0-dev.611787f.1730700274

This release adds a new compatbilityMode option to the startScanSession method:

const read = async () => {
  return new Promise((resolve) => {
    Nfc.addListener('nfcTagScanned', async (event) => {
      await Nfc.stopScanSession();
      resolve(event.nfcTag);
    });

    Nfc.startScanSession({
        compatbilityMode: true
    });
  });
};

Please give it a try and let me know if this resolves your issue.