Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow asynchronous passcode checking #27

Open
2 tasks done
thecodewarrior opened this issue Mar 28, 2018 · 2 comments
Open
2 tasks done

Allow asynchronous passcode checking #27

thecodewarrior opened this issue Mar 28, 2018 · 2 comments

Comments

@thecodewarrior
Copy link

thecodewarrior commented Mar 28, 2018

  • I have read this issue template and provided all possible information.
  • I'm using CocoaPods and have run pod update before filing this issue.

Hardware / Software

Which version of the library were you using? 0.0.2
Which version of iOS are you running? 11.2.6
What model of iOS device were you testing on? iPhone 6
If using CocoaPods, which version of CocoaPods are you on? 1.3.1

Goals

What is the outcome result you want to achieve with this library?
A custom child-lock passcode to restrict certain settings such as in-app purchases from kids.

Expected Results

What did you expect to happen?
When I finish inputting the passcode my passcode checking code is called and the UI does not freeze

Actual Results

What happened instead? (Please attach a screenshot/screen recording if possible)
Because the passcode checking is done in a blocking method on the main thread the UI pauses for about a second with the last dot of the passcode not filled, and then it suddenly animates away or performs the reset animation

In my opinion a good solution for this would be another delegate method, maybe passcodeViewController: performCodeCheck: that, if present, would immediately return out of didCompleteEnteringPasscode in the TOPasscodeViewController. There would have to be a method in TOPasscodeViewController that you could call to message a success or failure, such as didCheckPasscodeSuccess:, that would then call the same things as didCompleteEnteringPasscode: currently does on success/failure.

Edit: Currently I think you can sorta hack a solution by always succeeding and making didInputCorrectPasscode NOOP, then manually calling your success code or passcodeView.resetPasscode, but that method means that the passcodeSuccess variable is always going to be YES when dismissing the controller. I haven't tested this solution yet, but it may work.

@TimOliver
Copy link
Owner

That's a fantastic idea! I'll have to have a think about how to implement that one.

Some Apple APIs implement an asynchronous callback mechanism by providing a block to the delegate that needs to be called once the asynchronous logic has finished. That might be the best way here.

@aasatt
Copy link

aasatt commented Aug 6, 2018

I am also looking for this.

My thought would be to have two Delegates, the existing TOPasscodeViewControllerDelegate and aTOPasscodeViewControllerAsyncDelegate. It would be an "Exclusive Or" on which one you can implement and the controller would call whichever is set.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants