diff --git a/Sources/Controllers/PassCode/View/BasePassCodeViewController.swift b/Sources/Controllers/PassCode/View/BasePassCodeViewController.swift index 212a317..97f7b8f 100644 --- a/Sources/Controllers/PassCode/View/BasePassCodeViewController.swift +++ b/Sources/Controllers/PassCode/View/BasePassCodeViewController.swift @@ -77,7 +77,7 @@ open class BasePassCodeViewController: UIViewController, ConfigurableController initialLoadView() initialDotNumberConfiguration() configureBackgroundNotifications() - showBiometricsRequestIfNeeded(with: biometricsAuthorizationHint) + showBiometricsRequestIfNeeded() } override open func viewWillAppear(_ animated: Bool) { @@ -149,12 +149,14 @@ open class BasePassCodeViewController: UIViewController, ConfigurableController } } - private func showBiometricsRequestIfNeeded(with description: String) { + private func showBiometricsRequestIfNeeded() { guard viewModel.isBiometricsEnabled && viewModel.controllerType == .enter else { return } - viewModel.authenticateUsingBiometrics(with: description) + viewModel.authenticateUsingBiometrics(with: biometricsAuthorizationHint, + fallback: biometricsFallbackButtonTitle, + cancel: biometricsCancelButtonTitle) } private func resetUI() { @@ -166,10 +168,22 @@ open class BasePassCodeViewController: UIViewController, ConfigurableController /// Returns prompt that appears on touch id system alert open var biometricsAuthorizationHint: String { - assertionFailure("You should override this var: touchIdHint") + assertionFailure("You should override this \(#function)") return "" } + /// Returns prompt that appears on touch id system alert + open var biometricsFallbackButtonTitle: String? { + assertionFailure("You should override this \(#function)") + return nil + } + + /// Returns prompt that appears on touch id system alert + open var biometricsCancelButtonTitle: String? { + assertionFailure("You should override this \(#function)") + return nil + } + /// Override to point certain images open func imageFor(type: PinImageType) -> UIImage { assertionFailure("You should override this method: imageFor(type: PinImageType)") diff --git a/Sources/Controllers/PassCode/ViewModel/BasePassCodeViewModel.swift b/Sources/Controllers/PassCode/ViewModel/BasePassCodeViewModel.swift index 85006d4..55c4328 100644 --- a/Sources/Controllers/PassCode/ViewModel/BasePassCodeViewModel.swift +++ b/Sources/Controllers/PassCode/ViewModel/BasePassCodeViewModel.swift @@ -100,8 +100,8 @@ open class BasePassCodeViewModel: BaseViewModel { passCodeHolder.reset() } - public func authenticateUsingBiometrics(with description: String) { - biometricsService.authenticateWithBiometrics(with: description) { [weak self] success, error in + public func authenticateUsingBiometrics(with description: String, fallback: String?, cancel: String?) { + biometricsService.authenticateWithBiometrics(with: description, fallback: fallback, cancel: cancel) { [weak self] success, error in if success { self?.authSucceed(.touchId) } else { diff --git a/Sources/Services/BiometricsService.swift b/Sources/Services/BiometricsService.swift index fa257e9..cea4147 100644 --- a/Sources/Services/BiometricsService.swift +++ b/Sources/Services/BiometricsService.swift @@ -38,7 +38,9 @@ public final class BiometricsService { Initiates system biometrics authentication process - parameters: - - description: prompt on the system alert that describes what for user should attach finger to device + - description: prompt on the system alert + - fallback: alternative action button title on system alert + - cancel: cancel Button title on the system alert - authHandler: callback, with parameter, indicates if user authenticate successfuly */ public func authenticateWithBiometrics(with description: String,