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

Added restartPolling on iOS to be able to keep polling for multiple NFC tags after detecting one. #111

Merged
merged 4 commits into from Jun 20, 2023

Conversation

CollinHemeltjen
Copy link

Summary

Finding multiple NFC tags on iOS is pretty clunky business, one would have to show the scan modal multiple times which does not lead to a good user experience. NFCTagReaderSession does however have the option to restart polling after finding a tag, thus making it possible to scan more than one NFC tag per session.

I did add the variable shouldInvalidateAfterFirstRead so the library user can specify if they want this enabled, default behaviour is disabled and it is optional so we won't disturb any existing uses. The name shouldInvalidateAfterFirstRead is based on a similar function in NFCNDEFReaderSession.

How to test

In the example change _tagRead to the following:

 void _tagRead() {
    NfcManager.instance.startSession(invalidateAfterFirstRead: false, onDiscovered: (NfcTag tag) async {
      result.value = tag.data;
      // NfcManager.instance.stopSession();
    });
  }

After this you can spin up the example iOS app and test the scanning of multiple items on one request.

@claeszacho
Copy link

I just implemented this functionality into my own local fork of this project, and it works really well. This solves a lot of UX problems, that occurs with errors like loosing tag connection prematurely and so on...

@okadan could this be added to the project and prepared for release? It seems to be a rather small and simple implementation.

@okadan
Copy link
Owner

okadan commented Jun 20, 2023

Thank you both for your contribution.

For now, I will merge and release it.

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

Successfully merging this pull request may close these issues.

None yet

3 participants