Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TouchID calls applicationWillResignActive and applicationDidBecomeActive

Tags:

I am wondering if this is intended by Apple that these lifecycle methods are called upon using TouchID functionality.

Is there any possibility to check if the touchID process is calling these methods (I want to avoid things like a BOOL in app delegate which is set if touchID input is currently shown or not..)

br

like image 900
Chris K. Avatar asked Sep 25 '14 09:09

Chris K.


1 Answers

Im guessing the problem you're having is that you have code in applicationWillResignActive and applicationDidBecomeActive that affects the view controller that requests Touch ID-validation and that it sets off a tricky loop.

What you need to do is move those calls to applicationDidEnterBackground and applicationWillEnterForeground, because they're not invoked when the Touch ID-mechanism is called.

To explain the sequence, when your app starts the following sequence executes:

  1. applicationDidBecomeActive
  2. ..other stuff your app does
  3. Your app invokes Touch ID, which fires:
  4. applicationWillResignActive

... Your app is disabled until the user verifies fingerprint (fails or succeeds) ...

  1. applicationDidBecomeActive

If you have code in applicationDidBecomeActive -or- applicationWillResignActive that affects Touch ID, you will create an endless loop or worse, you will create code that is riddled with flags and special cases.

Instead you should invoke Touch ID in two cases:

  • When your app starts (usually in didFinishLaunchingWithOptions)

  • When your app's applicationWillEnterForeground is called.

like image 75
Mani Avatar answered Sep 19 '22 13:09

Mani