Fix NFC detection for already-present security keys#67
Open
RWebster-Noble wants to merge 1 commit into
Open
Conversation
Use enableReaderMode() instead of enableForegroundDispatch() to detect NFC tags already present when the authentication UI appears. This eliminates the condition where users had to remove and re-insert their security key.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix NFC tag detection for already-present cards
The credential provider activity was unable to detect NFC security keys that were already present when the authentication flow started. Users had to remove and re-insert their security key for the app to recognize it.
The root cause was that
enableForegroundDispatch()only triggers for tags discovered after it's enabled, not for tags already present on the NFC reader. This created a race condition where a key held during the initial prompt would be ignored.Switch to
enableReaderMode()which actively polls for NFC tags, allowing detection of already-present cards. This API (available since API 19) provides more reliable discovery for authentication flows where the user may already be holding their key when the UI appears.Implications and compatibility:
enableForegroundDispatch()is retained for compatibility, though it is not expected to be used given the app's minimum SDK requirement.Testing:
Tested using an Authentrend ATKey.Card NFC card. Verified that: