Skip to content

Commit 10f9e66

Browse files
authored
fix(biometric) prompt for fallback credentials when enabled and biometry unavailable on iOS (fix #2632) (#2633)
1 parent c97e9c5 commit 10f9e66

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"biometric": patch:bug
3+
"biometric-js": patch:bug
4+
---
5+
6+
Fix biometric plugin ignoring fallback logic when biometry status is unavailable or not enrolled on iOS.

plugins/biometric/ios/Sources/BiometricPlugin.swift

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,23 +98,24 @@ class BiometricPlugin: Plugin {
9898
}
9999

100100
@objc func authenticate(_ invoke: Invoke) throws {
101-
guard self.status.available else {
101+
let args = try invoke.parseArgs(AuthOptions.self)
102+
103+
let allowDeviceCredential = args.allowDeviceCredential ?? false
104+
105+
guard self.status.available || allowDeviceCredential else {
106+
// Biometry unavailable, fallback disabled
102107
invoke.reject(
103108
self.status.errorReason ?? "",
104109
code: self.status.errorCode ?? ""
105110
)
106111
return
107112
}
108113

109-
let args = try invoke.parseArgs(AuthOptions.self)
110-
111114
let context = LAContext()
112115
context.localizedFallbackTitle = args.fallbackTitle
113116
context.localizedCancelTitle = args.cancelTitle
114117
context.touchIDAuthenticationAllowableReuseDuration = 0
115118

116-
let allowDeviceCredential = args.allowDeviceCredential ?? false
117-
118119
// force system default fallback title if an empty string is provided (the OS hides the fallback button in this case)
119120
if allowDeviceCredential,
120121
let fallbackTitle = context.localizedFallbackTitle,

0 commit comments

Comments
 (0)