TOPasscodeViewController icon indicating copy to clipboard operation
TOPasscodeViewController copied to clipboard

Allow asynchronous passcode checking

Open thecodewarrior opened this issue 6 years ago • 2 comments

  • [x] I have read this issue template and provided all possible information.
  • [x] 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.

thecodewarrior avatar Mar 28 '18 01:03 thecodewarrior

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.

TimOliver avatar May 04 '18 03:05 TimOliver

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.

aasatt avatar Aug 06 '18 18:08 aasatt