Skip to content

Commit e20ef58

Browse files
committed
[local_auth_darwin] Handle when biometry hardware is available but permissions have been denied for the app
1 parent 6bf90e8 commit e20ef58

File tree

4 files changed

+30
-4
lines changed

4 files changed

+30
-4
lines changed

packages/local_auth/local_auth_darwin/CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
## NEXT
1+
## 1.4.3
22

3+
* Handles when biometry hardware is available but permissions have been denied for the app.
34
* Updates minimum supported SDK version to Flutter 3.22/Dart 3.4.
45

56
## 1.4.2

packages/local_auth/local_auth_darwin/darwin/Tests/FLALocalAuthPluginTests.swift

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ class FLALocalAuthPluginTests: XCTestCase {
447447
XCTAssertNil(error)
448448
}
449449

450-
func testDeviceSupportsBiometrics_withNoBiometricHardware() {
450+
func testDeviceSupportsBiometrics_withBiometryNotAvailable() {
451451
let stubAuthContext = StubAuthContext()
452452
let alertFactory = StubAlertFactory()
453453
let viewProvider = StubViewProvider()
@@ -456,14 +456,35 @@ class FLALocalAuthPluginTests: XCTestCase {
456456
alertFactory: alertFactory, viewProvider: viewProvider)
457457

458458
stubAuthContext.expectBiometrics = true
459-
stubAuthContext.canEvaluateError = NSError(domain: "error", code: 0)
459+
stubAuthContext.canEvaluateError = NSError(
460+
domain: "error", code: LAError.biometryNotAvailable.rawValue)
460461

461462
var error: FlutterError?
462463
let result = plugin.deviceCanSupportBiometricsWithError(&error)
463464
XCTAssertFalse(result!.boolValue)
464465
XCTAssertNil(error)
465466
}
466467

468+
469+
func testDeviceSupportsBiometrics_withBiometryNotAvailableLoadedBiometryType() {
470+
let stubAuthContext = StubAuthContext()
471+
let alertFactory = StubAlertFactory()
472+
let viewProvider = StubViewProvider()
473+
let plugin = FLALocalAuthPlugin(
474+
contextFactory: StubAuthContextFactory(contexts: [stubAuthContext]),
475+
alertFactory: alertFactory, viewProvider: viewProvider)
476+
477+
stubAuthContext.expectBiometrics = true
478+
stubAuthContext.biometryType = LABiometryType.touchID
479+
stubAuthContext.canEvaluateError = NSError(
480+
domain: "error", code: LAError.biometryNotAvailable.rawValue)
481+
482+
var error: FlutterError?
483+
let result = plugin.deviceCanSupportBiometricsWithError(&error)
484+
XCTAssertTrue(result!.boolValue)
485+
XCTAssertNil(error)
486+
}
487+
467488
func testGetEnrolledBiometricsWithFaceID() {
468489
let stubAuthContext = StubAuthContext()
469490
let alertFactory = StubAlertFactory()

packages/local_auth/local_auth_darwin/darwin/local_auth_darwin/Sources/local_auth_darwin/FLALocalAuthPlugin.m

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,10 @@ - (nullable NSNumber *)deviceCanSupportBiometricsWithError:
317317
if (authError.code == LAErrorBiometryNotEnrolled) {
318318
return @YES;
319319
}
320+
// Biometry hardware is available, but possibly permissions were denied.
321+
if (authError.code == LAErrorBiometryNotAvailable && context.biometryType != LABiometryTypeNone) {
322+
return @YES;
323+
}
320324
}
321325

322326
return @NO;

packages/local_auth/local_auth_darwin/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: local_auth_darwin
22
description: iOS implementation of the local_auth plugin.
33
repository: https://github.com/flutter/packages/tree/main/packages/local_auth/local_auth_darwin
44
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+local_auth%22
5-
version: 1.4.2
5+
version: 1.4.3
66

77
environment:
88
sdk: ^3.4.0

0 commit comments

Comments
 (0)