miki
miki

Reputation: 73

Passcode screen as login with confirmation, Swift

I created passcode screen with textfield and numpad. What I would like to do is: when user enters app first time, I would like to display him passcode screen where he will create his passcode, ones he enters something, passcode screen would pop out again, and ask user to re-enter passcode again, like a confirmation. And then on every other app start, he would use that passcode to access app.

I am not sure how could I use same screen multiple times and how should I check weather user already has passcode set up to know which screen should I show him.

Passcode that app asks user to enter, is not the one from phone (if user actually has one), this is app based passcode only.

TL:DR;

Flow: user launches app first time -> ask user to create passcode -> reopen screen and ask user to enter passcode again -> check value of passcode from first screen with second -> if matched, success -> every other app launch, ask user for passcode from first app launch, if success, let him access app.

Upvotes: 0

Views: 431

Answers (1)

Savvy
Savvy

Reputation: 629

You don't really want to 'pop out' that screen.. what would be a much better and easier approach to this would be to just let the user enter the passcode, and if it's the first time (meaning he needs to enter that passcode again to verify it, I guess) then just save his already entered passcode in a var inside your ViewController or ViewModel if you are using a MVVM architectural pattern, then just clear the passcode inside your UITextField, meaning:

yourTextfield.text = ""

So the user can re-enter the passcode, then you can check if the passcodes match. But no need at all to, 'pop out' the screen and then present it again.

Upvotes: 0

Related Questions