velikanov / SwiftPasscodeLock

An iOS passcode lock with TouchID authentication written in Swift.
MIT License
199 stars 52 forks source link

Make `authenticateWithBiometrics` public so as App can present it if needed #15

Closed ziogaschr closed 8 years ago

ziogaschr commented 8 years ago

Some apps need to be able to request TouchID immediately which is served by a nice option in the library. Furthermore, the nice thing with this library is that it can be easily extended for supporting more features. One feature that we have added to our app is passcode expiry after a time period. For example user wants to leave app unlocked for 3 minutes.

In this case our flow is as follows:

  1. When app moves to background
    • Passcode is presented
    • A splash view is being added
  2. When app comes to foreground
    • We check if Passcode is expired
      • remove splash view
      • if not expired:
      • dismisss passcode view
      • *

So for * the issue is that by setting shouldRequestTouchIDImmediately to true it will display the TouchID alert and there is no easy way to dismiss it. Apple has introduced LAContext().invalidate() at iOS9, although the animation has to happen and the user sees a flickering/annoying animation.

So instead of this, it works better to leave shouldRequestTouchIDImmediately to false and call authenticateWithBiometrics in our apps' code if needed.

p.s: passcodeConfiguration.shouldRequestTouchIDImmediately has been moved out of authenticateWithBiometrics as it doesn't feel to be in the right context and also caused the above scenario to not work.

younanjo commented 8 years ago

I was going to make the similar pull request and i noticed this by @ziogaschr . When the app is in background and user still has a valid "Session" come back to the app result in a cancelable touch-id prompt which is odd. please merge.

ziogaschr commented 8 years ago

@velikanov I plan to merge the PRs tomorrow if you don't have any considerations to add :)