Skip to content

Commit

Permalink
Fixed the request for TouchID authentication
Browse files Browse the repository at this point in the history
  • Loading branch information
Yanko Dimitrov committed Sep 10, 2015
1 parent d3b8ffe commit 71abaec
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
4 changes: 0 additions & 4 deletions PasscodeLock/PasscodeLock/PasscodeLock.swift
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,6 @@ public class PasscodeLock: PasscodeLockType {
if success {

self.delegate?.passcodeLockDidSucceed(self)

} else {

self.delegate?.passcodeLockDidFail(self)
}
}
}
Expand Down
18 changes: 9 additions & 9 deletions PasscodeLock/PasscodeLockViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class PasscodeLockViewController: UIViewController, PasscodeLockTypeDeleg
internal let passcodeLock: PasscodeLockType
internal var isPlaceholdersAnimationCompleted = true

private var shouldTryToAuthenticateWithBiometrics = false
private var shouldTryToAuthenticateWithBiometrics = true

// MARK: - Initializers

Expand Down Expand Up @@ -89,8 +89,10 @@ public class PasscodeLockViewController: UIViewController, PasscodeLockTypeDeleg
public override func viewDidAppear(animated: Bool) {
super.viewDidAppear(animated)

shouldTryToAuthenticateWithBiometrics = false
authenticateWithBiometrics()
if shouldTryToAuthenticateWithBiometrics {

authenticateWithBiometrics()
}
}

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

private func setupEvents() {

notificationCenter?.addObserver(self, selector: "appDidBecomeActiveHandler:", name: UIApplicationDidBecomeActiveNotification, object: nil)
notificationCenter?.addObserver(self, selector: "appWillEnterForegroundHandler:", name: UIApplicationWillEnterForegroundNotification, object: nil)
notificationCenter?.addObserver(self, selector: "appDidEnterBackgroundHandler:", name: UIApplicationDidEnterBackgroundNotification, object: nil)
}

private func clearEvents() {

notificationCenter?.removeObserver(self, name: UIApplicationDidBecomeActiveNotification, object: nil)
notificationCenter?.removeObserver(self, name: UIApplicationWillEnterForegroundNotification, object: nil)
notificationCenter?.removeObserver(self, name: UIApplicationDidEnterBackgroundNotification, object: nil)
}

public func appDidBecomeActiveHandler(notification: NSNotification) {

guard shouldTryToAuthenticateWithBiometrics else { return }
public func appWillEnterForegroundHandler(notification: NSNotification) {

authenticateWithBiometrics()
}

public func appDidEnterBackgroundHandler(notification: NSNotification) {

shouldTryToAuthenticateWithBiometrics = true
shouldTryToAuthenticateWithBiometrics = false
}

// MARK: - Actions
Expand Down

0 comments on commit 71abaec

Please sign in to comment.