Skip to content

Commit 71abaec

Browse files
author
Yanko Dimitrov
committed
Fixed the request for TouchID authentication
1 parent d3b8ffe commit 71abaec

File tree

2 files changed

+9
-13
lines changed

2 files changed

+9
-13
lines changed

PasscodeLock/PasscodeLock/PasscodeLock.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,6 @@ public class PasscodeLock: PasscodeLockType {
8484
if success {
8585

8686
self.delegate?.passcodeLockDidSucceed(self)
87-
88-
} else {
89-
90-
self.delegate?.passcodeLockDidFail(self)
9187
}
9288
}
9389
}

PasscodeLock/PasscodeLockViewController.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public class PasscodeLockViewController: UIViewController, PasscodeLockTypeDeleg
4343
internal let passcodeLock: PasscodeLockType
4444
internal var isPlaceholdersAnimationCompleted = true
4545

46-
private var shouldTryToAuthenticateWithBiometrics = false
46+
private var shouldTryToAuthenticateWithBiometrics = true
4747

4848
// MARK: - Initializers
4949

@@ -89,8 +89,10 @@ public class PasscodeLockViewController: UIViewController, PasscodeLockTypeDeleg
8989
public override func viewDidAppear(animated: Bool) {
9090
super.viewDidAppear(animated)
9191

92-
shouldTryToAuthenticateWithBiometrics = false
93-
authenticateWithBiometrics()
92+
if shouldTryToAuthenticateWithBiometrics {
93+
94+
authenticateWithBiometrics()
95+
}
9496
}
9597

9698
internal func updatePasscodeView() {
@@ -105,26 +107,24 @@ public class PasscodeLockViewController: UIViewController, PasscodeLockTypeDeleg
105107

106108
private func setupEvents() {
107109

108-
notificationCenter?.addObserver(self, selector: "appDidBecomeActiveHandler:", name: UIApplicationDidBecomeActiveNotification, object: nil)
110+
notificationCenter?.addObserver(self, selector: "appWillEnterForegroundHandler:", name: UIApplicationWillEnterForegroundNotification, object: nil)
109111
notificationCenter?.addObserver(self, selector: "appDidEnterBackgroundHandler:", name: UIApplicationDidEnterBackgroundNotification, object: nil)
110112
}
111113

112114
private func clearEvents() {
113115

114-
notificationCenter?.removeObserver(self, name: UIApplicationDidBecomeActiveNotification, object: nil)
116+
notificationCenter?.removeObserver(self, name: UIApplicationWillEnterForegroundNotification, object: nil)
115117
notificationCenter?.removeObserver(self, name: UIApplicationDidEnterBackgroundNotification, object: nil)
116118
}
117119

118-
public func appDidBecomeActiveHandler(notification: NSNotification) {
119-
120-
guard shouldTryToAuthenticateWithBiometrics else { return }
120+
public func appWillEnterForegroundHandler(notification: NSNotification) {
121121

122122
authenticateWithBiometrics()
123123
}
124124

125125
public func appDidEnterBackgroundHandler(notification: NSNotification) {
126126

127-
shouldTryToAuthenticateWithBiometrics = true
127+
shouldTryToAuthenticateWithBiometrics = false
128128
}
129129

130130
// MARK: - Actions

0 commit comments

Comments
 (0)