DEV Community

loading...
Cover image for Day 18: Swift macOS password manager for people who hate the cloud

Day 18: Swift macOS password manager for people who hate the cloud

swlkr profile image Sean Walker ・1 min read

<- For Day 17 go here

📅 01/18/2019
🚀 12 days until launch
🔥 17 day streak
💰 $2.99 price (into cup of coffee territory now)
🤑 $0 revenue
📈 0 customers
⌚️ 23 hours spent
💻 78 files changed, 246992 insertions(+), 54 deletions(-) (insertions are including 3rd party code 😬)
🏁 Today's goal: Touch ID support

5:05 PM
I keep racking up the hours on this thing!

5:30 PM
TouchID is surprisingly easy to do… here's the code

    import LocalAuthentication

    func showTouchID() {
        let context = LAContext()
        context.localizedCancelTitle = "Cancel"
        context.localizedFallbackTitle = "Unlock with password"

        var error: NSError?
        if context.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: &error) {
            let reason = "unlock AllYourPasswords"

            context.evaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, localizedReason: reason ) { success, error in

                if success {
                    // Move to the main thread because a state update triggers UI changes.
                    DispatchQueue.main.async { [unowned self] in
                        self.showPasswords()
                    }

                } else {
                    print(error?.localizedDescription ?? "Failed to authenticate")
                }
            }
        }
    }

I'll probably do something else tonight because that was only 20 minutes… here's what it looks like:

I'll be back 🕶

Turns out I had a life tonight! What! See you tomorrow 👉

Discussion (0)

pic
Editor guide