From f27ca6668f8059e931cd6f2da742441c03bdb6fd Mon Sep 17 00:00:00 2001 From: Dasmer Singh Date: Mon, 12 Jan 2015 10:16:39 -0500 Subject: [PATCH] Create VENTouchLockTouchIDResponsePromptAlreadyPresent --- VENTouchLock/VENTouchLock.h | 1 + VENTouchLock/VENTouchLock.m | 45 +++++++++++++++++++++---------------- 2 files changed, 27 insertions(+), 19 deletions(-) diff --git a/VENTouchLock/VENTouchLock.h b/VENTouchLock/VENTouchLock.h index a9ef20d..1c13626 100644 --- a/VENTouchLock/VENTouchLock.h +++ b/VENTouchLock/VENTouchLock.h @@ -9,6 +9,7 @@ typedef NS_ENUM(NSUInteger, VENTouchLockTouchIDResponse) { VENTouchLockTouchIDResponseSuccess, VENTouchLockTouchIDResponseUsePasscode, VENTouchLockTouchIDResponseCanceled, + VENTouchLockTouchIDResponsePromptAlreadyPresent, }; @interface VENTouchLock : NSObject diff --git a/VENTouchLock/VENTouchLock.m b/VENTouchLock/VENTouchLock.m index 0348f25..0280dae 100644 --- a/VENTouchLock/VENTouchLock.m +++ b/VENTouchLock/VENTouchLock.m @@ -128,22 +128,22 @@ - (void)requestTouchIDWithCompletion:(void (^)(VENTouchLockTouchIDResponse))comp - (void)requestTouchIDWithCompletion:(void (^)(VENTouchLockTouchIDResponse))completionBlock reason:(NSString *)reason { static BOOL isTouchIDPresented = NO; - if ([[self class] canUseTouchID] && !isTouchIDPresented) { - isTouchIDPresented = YES; - LAContext *context = [[LAContext alloc] init]; - context.localizedFallbackTitle = NSLocalizedString(@"Enter Passcode", nil); - [context evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics - localizedReason:reason - reply:^(BOOL success, NSError *error) { - isTouchIDPresented = NO; - dispatch_async(dispatch_get_main_queue(), ^{ - if (success) { - if (completionBlock) { - completionBlock(VENTouchLockTouchIDResponseSuccess); + if ([[self class] canUseTouchID]) { + if (!isTouchIDPresented) { + isTouchIDPresented = YES; + LAContext *context = [[LAContext alloc] init]; + context.localizedFallbackTitle = NSLocalizedString(@"Enter Passcode", nil); + [context evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics + localizedReason:reason + reply:^(BOOL success, NSError *error) { + isTouchIDPresented = NO; + dispatch_async(dispatch_get_main_queue(), ^{ + if (success) { + if (completionBlock) { + completionBlock(VENTouchLockTouchIDResponseSuccess); + } } - } - else { - if (completionBlock) { + else { VENTouchLockTouchIDResponse response; switch (error.code) { case LAErrorUserFallback: @@ -156,11 +156,18 @@ - (void)requestTouchIDWithCompletion:(void (^)(VENTouchLockTouchIDResponse))comp response = VENTouchLockTouchIDResponseUndefined; break; } - completionBlock(response); + if (completionBlock) { + completionBlock(response); + } } - } - }); - }]; + }); + }]; + } + else { + if (completionBlock) { + completionBlock(VENTouchLockTouchIDResponsePromptAlreadyPresent); + } + } } }