Search code examples
iosobjective-cios8touch-id

Touch ID on main queue


When authenticating with Touch ID in iOS 8, it goes a few seconds from authentication to my app goes from a authentication VC to a logged in VC. I replaced the direct method call on successful authentication with one that first got the main queue, and now it is super-fast. This is somehow related to Touch ID doing some work on a non-main queue, but I could not find any documentation or guidelines about this. Should all Touch ID related code be executed on the main queue, or just the result of the authentication?


Solution

  • Looking at the Apple example code you should make sure you are executing UI updates in the reply block on the main queue as it may be executing an asynchronous block.

    Here is the method that is used to process the result in that sample project -

    - (void)printResult:(UITextView*)textView message:(NSString*)msg
    {
        dispatch_async(dispatch_get_main_queue(), ^{
            // update the result in the main queue because we may be calling from asynchronous block
            textView.text = [textView.text stringByAppendingString:[NSString stringWithFormat:@"%@\n",msg]];
            [textView scrollRangeToVisible:NSMakeRange([textView.text length], 0)];
        });
    }