From 8bcc8bf110f5936384cb7f931453bd88236ad799 Mon Sep 17 00:00:00 2001 From: Andrey Chukavin Date: Tue, 15 Nov 2022 18:20:20 +0500 Subject: [PATCH] IOS-1943 Passing userCancelled from biometrics --- .../Common/Services/Secure/BiometricsUtil.swift | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/TangemSdk/TangemSdk/Common/Services/Secure/BiometricsUtil.swift b/TangemSdk/TangemSdk/Common/Services/Secure/BiometricsUtil.swift index ab8eabf9f..2d8b72575 100644 --- a/TangemSdk/TangemSdk/Common/Services/Secure/BiometricsUtil.swift +++ b/TangemSdk/TangemSdk/Common/Services/Secure/BiometricsUtil.swift @@ -36,10 +36,21 @@ public final class BiometricsUtil { DispatchQueue.global().async { context.evaluatePolicy(authenticationPolicy, localizedReason: localizedReason) { isSuccess, error in DispatchQueue.main.async { - if let error = error { - completion(.failure(error.toTangemSdkError())) - } else { + guard let error = error else { completion(.success(context)) + return + } + + guard let laError = error as? LAError else { + completion(.failure(error.toTangemSdkError())) + return + } + + switch laError.code { + case .userCancel, .appCancel, .systemCancel: + completion(.failure(.userCancelled)) + default: + completion(.failure(error.toTangemSdkError())) } } }