iOS Development Exchange Group: 484884085
You are welcome to increase.
For example, the following code is to implement the call of more than 5S device fingerprint identification code, according to the code given by the official website, will appear after the successful recognition after a very long time to run successfully after the call code, stroll for a very long time. Just know to put it into the main thread to achieve talent enough.
Detailed code such as the following.
1. Introduction of class Import Localauthentication
Call the fingerprint recognition function Func Loginwithtouchid () {if (Uidevice.currentdevice (). systemversionasnsstring). Floatvalue >= 8 .0) {//Get the local authentication context. Let context = Lacontext ()//Declare a nserror variable. var error:nserror? Set the reason string that'll appear on the authentication alert. var reasonstring = "The string that prompts the user when the Fingerprint identification box is popped"//Check if the device can evaluate the policy. If Context.canevaluatepolicy (lapolicy.deviceownerauthenticationwithbiometrics, Error: &error) { Context.evaluatepolicy (Lapolicy.deviceownerauthenticationwithbiometrics, localizedreason:reasonstring, reply: {( Success:bool, Evalpolicyerror:nserror?) -Voidin Dispatch_async (Dispatch_get_main_queue (), {(), voidin //put to the main thread to run. This is especially important if success {//Call after success what you want to do } else {//If authentication failed Then Show a message to the console with a short description. In case the error is a user fallback and then show the password Alert view. println (Evalpolicyerror?). localizeddescription)})})} else {//If the security policy cannot is evaluated then show a short message depending on the error. Switch error!. Code {caseLAError.TouchIDNotEnrolled.rawValue: println ("You have not saved touch ID fingerprint ") caseLAError.PasscodeNotSet.rawValue:println (" You have not set a password ") Default: The laerror.touchidnotavailable case. println ("TouchID Not Available")}//Optionally the error description can be displayed on the console. println (Error?). localizeddescription)//Show The custom Alert view to allow users to enter the password. } } }
Swift downgrades with Touch ID for fingerprint recognition