IOS 8 uses Touch ID for user authentication, iostouch
The iOS 8 SDK opens the Touch ID interface. from the WWDC video, we can see that Touch ID is applied in two aspects: Key Chain encryption and authorization. after the official version of iOS 8 is released, we can see that the iOS app of Evernote has integrated this function. next let's take a look at how to use Touch ID for identity authentication. in fact, it is very simple. All the interfaces used for identity authentication are in the LocalAuthentication framework. The framework actually has only three header files: LAContext. h LAError. h LAPublicDefines. h. Actually, there are only two functions used: // used to determine whether the device supports Touch ID-(BOOL) canEvaluatePolicy :( LAPolicy) policy error :( NSError * _ autoreleasing *) error; // function for real identity authentication-(void) evaluatePolicy :( LAPolicy) policy localizedReason :( NSString *) localizedReason
Reply :( void (^) (BOOL success, NSError * error) reply;
Both of the above functions are LAContext's member functions. Currently, LAPolicy has only one value: LAPolicyDeviceOwnerAuthenticationWithBiometrics.
If canEvaluatePolicy returns YES, indicating that the device supports fingerprint recognition, you can call the evaluatePolicy function for fingerprint recognition. After the evaluatePolicy function is called, an alert will pop up, for example:
This alert can be customized in only two ways: 1. the prompt text "To access your photos" is specified by the localizedReason parameter To explain the purpose of using Touch ID To users. 2. "Enter Password" can be set by the localizedFallbackTitle attribute of LAContext (LAContext currently only has this attribute). If it is not set, the default value is "Enter Password ". it is worth noting that if this attribute is set to @ "" (Null String), this button will be hidden, and Evernote should do this. for other things, let alone retrieve the user's fingerprint data. in theory, the verification will exit in three cases (alert will be dismiss, and reply callback will be called): 1. user fingerprint verification 2. click Enter Password. you can also click "Cancel". The user entered an incorrect fingerprint. in this case, the alert will not be dismiss, and its title will be changed from "Touch ID" to "Try Again", with a spring animation effect transition. okay, the Code is as follows (do not forget to introduce the header file <LocalAuthentication/LocalAuthentication. h>): LAContext * context = [LAContext new];
NSError * error;
Context. localizedFallbackTitle = @"";
If ([context canEvaluatePolicy: LAPolicyDeviceOwnerAuthenticationWithBiometrics error: & error]) {
NSLog (@ "Touch ID is available .");
[Context evaluatePolicy: LAPolicyDeviceOwnerAuthenticationWithBiometrics localizedReason: NSLocalizedString (@ "Use Touch ID to log in.", nil) reply: ^ (BOOL success, NSError * error ){
If (success ){
NSLog (@ "Authenticated using Touch ID .");
} Else {if (error. code = kLAErrorUserFallback) {NSLog (@ "User tapped Enter Password ");
} Else if (error. code = kLAErrorUserCancel ){
NSLog (@ "User tapped Cancel ");
} Else {
NSLog (@ "Authenticated failed .");}
}];
} Else {
NSLog (@ "Touch ID is not available: % @", error );
}
The touch ID becomes invalid after ios802 is upgraded.
Hello, ios8.0.2 solves the problem of fingerprint identification, but it is recommended that you restore the system in iTunes again, followed by restoring all the settings of the mobile phone, restart the mobile phone to check whether the problem persists. 3. Call Apple's official after-sales customer service to ask them about the solution. 4. Check the local after-sales service to check whether the fault caused by the hardware problem exists. The following is an update of ios8.0.2:
Ask how iphone 5 can be used with Touch ID, which has been upgraded to ios71
Currently, fingerprint sensors are available for iPhone 5s.