From 10f9e66e32141dd35f4bf884fbf9102691187e92 Mon Sep 17 00:00:00 2001 From: "Patrick F." <28768673+pjf-dev@users.noreply.github.com> Date: Wed, 16 Apr 2025 16:56:43 -0400 Subject: [PATCH] fix(biometric) prompt for fallback credentials when enabled and biometry unavailable on iOS (fix #2632) (#2633) --- .changes/fix-ios-biometry-fallback-auth.md | 6 ++++++ plugins/biometric/ios/Sources/BiometricPlugin.swift | 11 ++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) create mode 100644 .changes/fix-ios-biometry-fallback-auth.md diff --git a/.changes/fix-ios-biometry-fallback-auth.md b/.changes/fix-ios-biometry-fallback-auth.md new file mode 100644 index 000000000..c01159f0e --- /dev/null +++ b/.changes/fix-ios-biometry-fallback-auth.md @@ -0,0 +1,6 @@ +--- +"biometric": patch:bug +"biometric-js": patch:bug +--- + +Fix biometric plugin ignoring fallback logic when biometry status is unavailable or not enrolled on iOS. diff --git a/plugins/biometric/ios/Sources/BiometricPlugin.swift b/plugins/biometric/ios/Sources/BiometricPlugin.swift index 3c9a192a8..c295904aa 100644 --- a/plugins/biometric/ios/Sources/BiometricPlugin.swift +++ b/plugins/biometric/ios/Sources/BiometricPlugin.swift @@ -98,7 +98,12 @@ class BiometricPlugin: Plugin { } @objc func authenticate(_ invoke: Invoke) throws { - guard self.status.available else { + let args = try invoke.parseArgs(AuthOptions.self) + + let allowDeviceCredential = args.allowDeviceCredential ?? false + + guard self.status.available || allowDeviceCredential else { + // Biometry unavailable, fallback disabled invoke.reject( self.status.errorReason ?? "", code: self.status.errorCode ?? "" @@ -106,15 +111,11 @@ class BiometricPlugin: Plugin { return } - let args = try invoke.parseArgs(AuthOptions.self) - let context = LAContext() context.localizedFallbackTitle = args.fallbackTitle context.localizedCancelTitle = args.cancelTitle context.touchIDAuthenticationAllowableReuseDuration = 0 - let allowDeviceCredential = args.allowDeviceCredential ?? false - // force system default fallback title if an empty string is provided (the OS hides the fallback button in this case) if allowDeviceCredential, let fallbackTitle = context.localizedFallbackTitle,