Skip to content

Commit 856d909

Browse files
committed
Updated Touch ID policy
1 parent a7d4baa commit 856d909

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

TOPasscodeViewControllerExample/ViewController.m

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,29 @@ - (void)didPerformBiometricValidationRequestInPasscodeViewController:(TOPasscode
8888
__weak typeof(self) weakSelf = self;
8989
NSString *reason = @"Touch ID to continue using this app";
9090
id reply = ^(BOOL success, NSError *error) {
91-
if (!success) {
92-
NSLog(@"%@", error.localizedDescription);
91+
92+
// Touch ID validation was successful
93+
// (Use this to dismiss the passcode controller and display the protected content)
94+
if (success) {
95+
// Create a new Touch ID context for next time
96+
[weakSelf.authContext invalidate];
97+
weakSelf.authContext = [[LAContext alloc] init];
98+
99+
// Dismiss the passcode controller
100+
[weakSelf dismissViewControllerAnimated:YES completion:nil];
93101
return;
94102
}
95103

96-
[weakSelf dismissViewControllerAnimated:YES completion:nil];
104+
// The user hit the 'Cancel' button in the Touch ID dialog
105+
// (Use this to dismiss the controller if desired, but do not show the protected content)
106+
if (error.code == LAErrorUserCancel) {
107+
[weakSelf dismissViewControllerAnimated:YES completion:nil];
108+
return;
109+
}
110+
111+
// The other main error would be if the user hit 'Enter Passcode', in which case they can enter
112+
// their passcode manually into the passcode controller
113+
NSLog(@"%@", error.localizedDescription);
97114
};
98115

99116
[self.authContext evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics localizedReason:reason reply:reply];

0 commit comments

Comments
 (0)