capawesome-team/capacitor-nfc

feat: Add support for session option invalidateAfterFirstRead: false on iOS

sparud opened this issue · 3 comments

sparud commented

Is your feature request related to a problem? Please describe:
I'd like to read multiple tags (actually 52, it's a deck of playing cards with RFID). After each card I'd want to show on the screen which player (this is for playing bridge) shoudl have the card. With the current interface it's hard to do that. I have to start a session for each card and wait for the success dialogue to disappear (after about three seconds) before I can start listening for the next card. And there is no event signalling that the success view disappears.

Describe the solution you'd like:
If i read the iOS documentation correctly there is a session option invalidateAfterFirstRead: false that keeps the session live until killed by doing session.invalidate() (which I guess is Nfc.stopScanSession()). If the invalidation is called immediately when the receive event is called, the success view will not be shown or removed immediately, which is what I want.

Are there any plans of adding support for invalidateAfterFirstRead?

Describe alternatives you've considered:

Additional context:

Thank you for your request!
invalidateAfterFirstRead does the same as if you call stopScanSession(...) directly after reading the tag:

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

    Nfc.startScanSession();
  });
};

Neither the popup nor the animation can be disabled on iOS unfortunately (see https://stackoverflow.com/a/47731094/6731412).

Also, invalidateAfterFirstRead is only available in the NFCNDEFReaderSession. However, this plugin uses the newer NFCTagReaderSession.

I could still offer you to add an option that automatically stops the session after the first scan, so you don't have to call stopScanSession(...) yourself. But this will not use invalidateAfterFirstRead.

sparud commented

OK, thanks. I thought it would be possible to control the success screen display, or at least to be able to dynamically show something on it depending on the tag read.

Unfortunately not. In this case I am closing this issue.