File tree Expand file tree Collapse file tree 1 file changed +20
-3
lines changed
TOPasscodeViewControllerExample Expand file tree Collapse file tree 1 file changed +20
-3
lines changed Original file line number Diff line number Diff line change @@ -88,12 +88,29 @@ - (void)didPerformBiometricValidationRequestInPasscodeViewController:(TOPasscode
88
88
__weak typeof (self) weakSelf = self;
89
89
NSString *reason = @" Touch ID to continue using this app" ;
90
90
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 ];
93
101
return ;
94
102
}
95
103
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 );
97
114
};
98
115
99
116
[self .authContext evaluatePolicy: LAPolicyDeviceOwnerAuthenticationWithBiometrics localizedReason: reason reply: reply];
You can’t perform that action at this time.
0 commit comments