Repository navigation
Report a started biometric prompt as started - #522
Open
prosenthal828 wants to merge 1 commit into
Open
prosenthal828 wants to merge 1 commit into
prosenthal828 wants to merge 1 commit into
Conversation
PendingBiometric::prompt() only returned true for {"status": "success"},
but BridgeResponse.success() on Android and iOS returns the function's data
unwrapped and only errors carry a status key. mobile-biometrics answers
{"launched": true} on Android and {} on iOS, so prompt() returned false for
a prompt that was on screen.
Treat any answer that is not {"status": "error", ...} as started, the same
check PendingMicrophone already uses. A missing bridge function (null) still
returns false.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Problem
PendingBiometric::prompt()returnstrueonly when the bridge answers{"status": "success"}. No bridge function answers that:BridgeResponse.success()(Kotlin and Swift) returns the function's data as-is, and only errors carry astatuskey ({"status": "error", "code": ..., "message": ...}).nativephp/mobile-biometrics 1.0.3 answers
{"launched": true}on Android and{}on iOS, soBiometrics::prompt()->prompt()returnsfalsewhile the fingerprint / Touch ID sheet is on screen. Code that checks the return value (for example to fall back to a PIN when biometrics can't start) takes the fallback every time.Fix
Treat any answer that isn't
{"status": "error", ...}as started.PendingMicrophone::start()already does this. A missing bridge function (nativephp_call()returns null) still returnsfalse. The result of the prompt still arrives asNative\Mobile\Events\Biometric\Completed.The plugin is not the side to change:
{"launched": true}/{}follow the core bridge contract, and wrapping its answer instatus: successwould make it the only bridge function that does.Tests
New
tests/Unit/Biometrics/PendingBiometricTest.php(FakeBridge):idand the event class toBiometric.Prompt{"launched":true},{}and[]count as started (these fail on main){"status":"error", ...}and a missing bridge function don'tprompt()only calls the bridge onceFull suite on the branch: 1499 passed, 3 skipped, 4 risky (same skipped/risky as main).
Tested on real devices
Core 4.5.2 with this change, nativephp/mobile-biometrics 1.0.3, debug builds. A test app routed its unlock screen through
Biometrics::prompt()->id($id)->prompt()and logged the return value.{"launched":true}andprompt()returnedtrue. The system biometric prompt was on screen (BiometricPromptRootwindow). A real fingerprint then deliveredCompletedwithsuccess: trueand the matching id. Seen twice.prompt()returnedtrueand Touch ID came up. A real Touch ID then deliveredCompletedwithsuccess: true. Seen twice.Same pattern, not changed here:
PendingPhotoCapture,PendingVideoRecorderandPendingMediaPickeralso compare againststatus === 'success'. Happy to send those as a follow-up if you want them fixed the same way.🤖 Generated with Claude Code