IOS Touch ID Usage details
Last Update:2016-05-12
Source: Internet
Author: User
<span id="Label3"></p><p><p><span style="color:rgb(47,47,47); font-family:‘lucida grande‘,‘lucida sans unicode‘,lucida,helvetica,‘Hiragino Sans GB‘,‘Microsoft YaHei‘,‘WenQuanYi Micro Hei‘,sans-serif; font-size:15px; text-align:justify; background-color:rgb(245,245,245)">Brief introduction:</span></p></p><p><p><span style="color:rgb(47,47,47); font-family:‘lucida grande‘,‘lucida sans unicode‘,lucida,helvetica,‘Hiragino Sans GB‘,‘Microsoft YaHei‘,‘WenQuanYi Micro Hei‘,sans-serif; font-size:15px; text-align:justify; background-color:rgb(245,245,245)"></span></p></p><p style="margin-top:0px; margin-bottom:25px; text-align:justify; word-break:break-word; color:rgb(47,47,47); font-family:‘lucida grande‘,‘lucida sans unicode‘,lucida,helvetica,‘Hiragino Sans GB‘,‘Microsoft YaHei‘,‘WenQuanYi Micro Hei‘,sans-serif; font-size:16px"><p style="margin-top:0px; margin-bottom:25px; text-align:justify; word-break:break-word; color:rgb(47,47,47); font-family:‘lucida grande‘,‘lucida sans unicode‘,lucida,helvetica,‘Hiragino Sans GB‘,‘Microsoft YaHei‘,‘WenQuanYi Micro Hei‘,sans-serif; font-size:16px"><strong>Support Systems and Models</strong></p></p><p style="margin-top:0px; margin-bottom:25px; text-align:justify; word-break:break-word; color:rgb(47,47,47); font-family:‘lucida grande‘,‘lucida sans unicode‘,lucida,helvetica,‘Hiragino Sans GB‘,‘Microsoft YaHei‘,‘WenQuanYi Micro Hei‘,sans-serif; font-size:16px"><p style="margin-top:0px; margin-bottom:25px; text-align:justify; word-break:break-word; color:rgb(47,47,47); font-family:‘lucida grande‘,‘lucida sans unicode‘,lucida,helvetica,‘Hiragino Sans GB‘,‘Microsoft YaHei‘,‘WenQuanYi Micro Hei‘,sans-serif; font-size:16px">The iOS System's fingerprint recognition feature has the lowest supported model for the iphone 5s, the minimum support system for iOS 8, although the installation of the iOS 7 system of the 5s model can use the system-provided fingerprint unlock function, But because the API is not open, so theoretically third-party software is not available.</p></p><p><p><strong>Dependency Framework</strong><br>Localauthentication.framework<br>Import <LocalAuthentication/LocalAuthentication.h></p></p><p><p><strong>Precautions</strong><br>When you do the following versions of iOS 8, be sure to validate the API to avoid invoking the associated API to cause a Crash.</p></p><p><p><strong>Using classes<br>Lacontext</strong> Fingerprint Validation Action object</p></p><br><span style="color:rgb(47,47,47); font-family:‘lucida grande‘,‘lucida sans unicode‘,lucida,helvetica,‘Hiragino Sans GB‘,‘Microsoft YaHei‘,‘WenQuanYi Micro Hei‘,sans-serif; font-size:15px; text-align:justify; background-color:rgb(245,245,245)"><span style="color:rgb(47,47,47); font-family:‘lucida grande‘,‘lucida sans unicode‘,lucida,helvetica,‘Hiragino Sans GB‘,‘Microsoft YaHei‘,‘WenQuanYi Micro Hei‘,sans-serif; font-size:15px; text-align:justify; background-color:rgb(245,245,245)">Code implementation:</span></span><p><p><span style="color:rgb(47,47,47); font-family:‘lucida grande‘,‘lucida sans unicode‘,lucida,helvetica,‘Hiragino Sans GB‘,‘Microsoft YaHei‘,‘WenQuanYi Micro Hei‘,sans-serif; font-size:15px; text-align:justify; background-color:rgb(245,245,245)"><span style="color:rgb(47,47,47); font-family:‘lucida grande‘,‘lucida sans unicode‘,lucida,helvetica,‘Hiragino Sans GB‘,‘Microsoft YaHei‘,‘WenQuanYi Micro Hei‘,sans-serif; font-size:15px; text-align:justify; background-color:rgb(245,245,245)"></span></span></p></p><pre class="hljs objectivec" style="padding:9.5px; font-family:Menlo,Monaco,Consolas,‘Courier New‘,monospace; font-size:13px; color:rgb(101,123,131); margin-top:0px; margin-bottom:20px; line-height:20px; word-break:break-all; word-wrap:normal; background-color:rgb(253,246,227); overflow:auto"><code class="objectivec" style="padding:0px; font-family:Menlo,Monaco,Consolas,‘Courier New‘,monospace; font-size:12px; background-color:transparent; border:none"><span class="hljs-comment" style="color:rgb(147,161,161)"><span class="hljs-comment" style="color:rgb(147,161,161)">//initialize Context Object</span></span>lacontext* context = [[lacontext alloc] init];<span class="hljs-comment" style="color:rgb(147,161,161)"><span class="hljs-comment" style="color:rgb(147,161,161)">//error Object</span></span> <span class="hljs-built_in" style="color:rgb(38,139,210)"><span class="hljs-built_in" style="color:rgb(38,139,210)">Nserror</span></span>* ERROR =<span class="hljs-literal"><span class="hljs-literal">Nil</span></span>;<span class="hljs-built_in" style="color:rgb(38,139,210)"><span class="hljs-built_in" style="color:rgb(38,139,210)">NSString</span></span>* result =<span class="hljs-string" style="color:rgb(42,161,152)"><span class="hljs-string" style="color:rgb(42,161,152)">@ "validate"</span></span>; Context<span class="hljs-variable" style="color:rgb(181,137,0)"><span class="hljs-variable" style="color:rgb(181,137,0)">. Localizedfallbacktitle</span></span>=<span class="hljs-string" style="color:rgb(42,161,152)"><span class="hljs-string" style="color:rgb(42,161,152)">@ "123"</span></span>;<span class="hljs-comment" style="color:rgb(147,161,161)"><span class="hljs-comment" style="color:rgb(147,161,161)">//determine If the device supports TouchID</span></span> <span class="hljs-built_in" style="color:rgb(38,139,210)"><span class="hljs-built_in" style="color:rgb(38,139,210)">BOOL</span></span>Issupport = [context Canevaluatepolicy:lapolicydeviceownerauthenticationwithbiometrics error:&error];<span class="hljs-keyword" style="color:rgb(133,153,0)"><span class="hljs-keyword" style="color:rgb(133,153,0)">if</span></span>(issupport) {<span class="hljs-comment" style="color:rgb(147,161,161)"><span class="hljs-comment" style="color:rgb(147,161,161)">//fingerprint recognition Function</span></span>[context Evaluatepolicy:lapolicydeviceownerauthenticationwithbiometrics localizedreason:<span class="hljs-string" style="color:rgb(42,161,152)"><span class="hljs-string" style="color:rgb(42,161,152)">@ "sign in with Touch ID"</span></span>reply:^ (<span class="hljs-built_in" style="color:rgb(38,139,210)"><span class="hljs-built_in" style="color:rgb(38,139,210)">BOOL</span></span>Success<span class="hljs-built_in" style="color:rgb(38,139,210)"><span class="hljs-built_in" style="color:rgb(38,139,210)">Nserror</span></span>*error) {<span class="hljs-comment" style="color:rgb(147,161,161)"><span class="hljs-comment" style="color:rgb(147,161,161)">//if successful</span></span> <span class="hljs-keyword" style="color:rgb(133,153,0)"><span class="hljs-keyword" style="color:rgb(133,153,0)">if</span></span>(success) {<span class="hljs-built_in" style="color:rgb(38,139,210)"><span class="hljs-built_in" style="color:rgb(38,139,210)">NSLog</span></span>(<span class="hljs-string" style="color:rgb(42,161,152)"><span class="hljs-string" style="color:rgb(42,161,152)">@ "verify success"</span></span>); }<span class="hljs-keyword" style="color:rgb(133,153,0)"><span class="hljs-keyword" style="color:rgb(133,153,0)">Else</span></span>{<span class="hljs-keyword" style="color:rgb(133,153,0)"><span class="hljs-keyword" style="color:rgb(133,153,0)">Switch</span></span>(error<span class="hljs-variable" style="color:rgb(181,137,0)"><span class="hljs-variable" style="color:rgb(181,137,0)">. Code</span></span>) {<span class="hljs-keyword" style="color:rgb(133,153,0)"><span class="hljs-keyword" style="color:rgb(133,153,0)"></span> case</span>Laerrorsystemcancel: {<span class="hljs-built_in" style="color:rgb(38,139,210)"><span class="hljs-built_in" style="color:rgb(38,139,210)">NSLog</span></span>(<span class="hljs-string" style="color:rgb(42,161,152)"><span class="hljs-string" style="color:rgb(42,161,152)">@ "authentication is cancelled by the system"</span></span>);<span class="hljs-comment" style="color:rgb(147,161,161)"><span class="hljs-comment" style="color:rgb(147,161,161)">//switch to another app, the system cancels the verification touch ID</span></span> <span class="hljs-keyword" style="color:rgb(133,153,0)"><span class="hljs-keyword" style="color:rgb(133,153,0)"></span> break</span>; }<span class="hljs-keyword" style="color:rgb(133,153,0)"><span class="hljs-keyword" style="color:rgb(133,153,0)"></span> case</span>Laerrorusercancel: {<span class="hljs-built_in" style="color:rgb(38,139,210)"><span class="hljs-built_in" style="color:rgb(38,139,210)">NSLog</span></span>(<span class="hljs-string" style="color:rgb(42,161,152)"><span class="hljs-string" style="color:rgb(42,161,152)">@ "authentication is cancelled by the user"</span></span>);<span class="hljs-comment" style="color:rgb(147,161,161)"><span class="hljs-comment" style="color:rgb(147,161,161)">//user cancels authentication touch ID</span></span> <span class="hljs-keyword" style="color:rgb(133,153,0)"><span class="hljs-keyword" style="color:rgb(133,153,0)"></span> break</span>; }<span class="hljs-keyword" style="color:rgb(133,153,0)"><span class="hljs-keyword" style="color:rgb(133,153,0)"></span> case</span>laerroruserfallback: {<span class="hljs-built_in" style="color:rgb(38,139,210)"><span class="hljs-built_in" style="color:rgb(38,139,210)">NSLog</span></span>(<span class="hljs-string" style="color:rgb(42,161,152)"><span class="hljs-string" style="color:rgb(42,161,152)">@ "User selected to enter custom password"</span></span>); [[<span class="hljs-built_in" style="color:rgb(38,139,210)"><span class="hljs-built_in" style="color:rgb(38,139,210)">Nsoperationqueue</span></span>mainqueue] addoperationwithblock:^{<span class="hljs-comment" style="color:rgb(147,161,161)"><span class="hljs-comment" style="color:rgb(147,161,161)">//user Select Enter password, switch main thread processing</span></span>}];<span class="hljs-keyword" style="color:rgb(133,153,0)"><span class="hljs-keyword" style="color:rgb(133,153,0)"></span> break</span>; } } } }];}<span class="hljs-keyword" style="color:rgb(133,153,0)"><span class="hljs-keyword" style="color:rgb(133,153,0)">Else</span></span>{<span class="hljs-keyword" style="color:rgb(133,153,0)"><span class="hljs-keyword" style="color:rgb(133,153,0)">Switch</span></span>(error<span class="hljs-variable" style="color:rgb(181,137,0)"><span class="hljs-variable" style="color:rgb(181,137,0)">. Code</span></span>) {<span class="hljs-keyword" style="color:rgb(133,153,0)"><span class="hljs-keyword" style="color:rgb(133,153,0)"></span> case</span>laerrortouchidnotenrolled: {<span class="hljs-built_in" style="color:rgb(38,139,210)"><span class="hljs-built_in" style="color:rgb(38,139,210)">NSLog</span></span>(<span class="hljs-string" style="color:rgb(42,161,152)"><span class="hljs-string" style="color:rgb(42,161,152)">@ "TouchID is not enrolled"</span></span>);<span class="hljs-keyword" style="color:rgb(133,153,0)"><span class="hljs-keyword" style="color:rgb(133,153,0)"></span> break</span>; }<span class="hljs-keyword" style="color:rgb(133,153,0)"><span class="hljs-keyword" style="color:rgb(133,153,0)"></span> case</span>laerrorpasscodenotset: {<span class="hljs-built_in" style="color:rgb(38,139,210)"><span class="hljs-built_in" style="color:rgb(38,139,210)">NSLog</span></span>(<span class="hljs-string" style="color:rgb(42,161,152)"><span class="hljs-string" style="color:rgb(42,161,152)">@ "A passcode have not been set"</span></span>);<span class="hljs-keyword" style="color:rgb(133,153,0)"><span class="hljs-keyword" style="color:rgb(133,153,0)"></span> break</span>; }<span class="hljs-keyword" style="color:rgb(133,153,0)"><span class="hljs-keyword" style="color:rgb(133,153,0)">default</span></span>: {<span class="hljs-built_in" style="color:rgb(38,139,210)"><span class="hljs-built_in" style="color:rgb(38,139,210)">NSLog</span></span>(<span class="hljs-string" style="color:rgb(42,161,152)"><span class="hljs-string" style="color:rgb(42,161,152)">@ "TouchID not available"</span></span>);<span class="hljs-keyword" style="color:rgb(133,153,0)"><span class="hljs-keyword" style="color:rgb(133,153,0)"></span> break</span>; } }<span class="hljs-built_in" style="color:rgb(38,139,210)"><span class="hljs-built_in" style="color:rgb(38,139,210)">NSLog</span></span>(<span class="hljs-string" style="color:rgb(42,161,152)"><span class="hljs-string" style="color:rgb(42,161,152)">@"%@"</span></span>, error<span class="hljs-variable" style="color:rgb(181,137,0)"><span class="hljs-variable" style="color:rgb(181,137,0)">. Localizeddescription</span></span>);}</code></pre><span style="color:rgb(47,47,47); font-family:‘lucida grande‘,‘lucida sans unicode‘,lucida,helvetica,‘Hiragino Sans GB‘,‘Microsoft YaHei‘,‘WenQuanYi Micro Hei‘,sans-serif; font-size:15px; text-align:justify"><span style="color:rgb(47,47,47); font-family:‘lucida grande‘,‘lucida sans unicode‘,lucida,helvetica,‘Hiragino Sans GB‘,‘Microsoft YaHei‘,‘WenQuanYi Micro Hei‘,sans-serif; font-size:15px; text-align:justify">here is the meaning of each enumeration in Laerror</span></span><br><p><p></p></p><p><p><span style="color:rgb(47,47,47); font-family:‘lucida grande‘,‘lucida sans unicode‘,lucida,helvetica,‘Hiragino Sans GB‘,‘Microsoft YaHei‘,‘WenQuanYi Micro Hei‘,sans-serif; font-size:15px; text-align:justify; background-color:rgb(245,245,245)"><span style="color:rgb(47,47,47); font-family:‘lucida grande‘,‘lucida sans unicode‘,lucida,helvetica,‘Hiragino Sans GB‘,‘Microsoft YaHei‘,‘WenQuanYi Micro Hei‘,sans-serif; font-size:15px; text-align:justify; background-color:rgb(245,245,245)"><span style="color:rgb(47,47,47); font-family:‘lucida grande‘,‘lucida sans unicode‘,lucida,helvetica,‘Hiragino Sans GB‘,‘Microsoft YaHei‘,‘WenQuanYi Micro Hei‘,sans-serif; font-size:15px; text-align:justify"></span></span></span></p></p><pre class="hljs objectivec" style="padding:9.5px; font-family:Menlo,Monaco,Consolas,‘Courier New‘,monospace; font-size:13px; color:rgb(101,123,131); margin-top:0px; margin-bottom:20px; line-height:20px; word-break:break-all; word-wrap:normal; background-color:rgb(253,246,227); overflow:auto"><code class="objectivec" style="padding:0px; font-family:Menlo,Monaco,Consolas,‘Courier New‘,monospace; font-size:12px; background-color:transparent; border:none"><span class="hljs-keyword" style="color:rgb(133,153,0)"><span class="hljs-keyword" style="color:rgb(133,153,0)">typedef</span></span> <span class="hljs-built_in" style="color:rgb(38,139,210)"><span class="hljs-built_in" style="color:rgb(38,139,210)">Ns_enum</span></span>(<span class="hljs-built_in" style="color:rgb(38,139,210)"><span class="hljs-built_in" style="color:rgb(38,139,210)">Nsinteger</span></span>, Laerror) {<span class="hljs-comment" style="color:rgb(147,161,161)"><span class="hljs-comment" style="color:rgb(147,161,161)">//authorization failed</span></span>laerrorauthenticationfailed = klaerrorauthenticationfailed,<span class="hljs-comment" style="color:rgb(147,161,161)"><span class="hljs-comment" style="color:rgb(147,161,161)">//user cancels Touch ID authorization</span></span>Laerrorusercancel = klaerrorusercancel,<span class="hljs-comment" style="color:rgb(147,161,161)"><span class="hljs-comment" style="color:rgb(147,161,161)">//user chooses to enter password</span></span>Laerroruserfallback = klaerroruserfallback,<span class="hljs-comment" style="color:rgb(147,161,161)"><span class="hljs-comment" style="color:rgb(147,161,161)">//system de-authorization (such as other app Cut-in)</span></span>Laerrorsystemcancel = klaerrorsystemcancel,<span class="hljs-comment" style="color:rgb(147,161,161)"><span class="hljs-comment" style="color:rgb(147,161,161)">//system not set password</span></span>Laerrorpasscodenotset = klaerrorpasscodenotset,<span class="hljs-comment" style="color:rgb(147,161,161)"><span class="hljs-comment" style="color:rgb(147,161,161)">//device Touch ID not available, e.g. not open</span></span>Laerrortouchidnotavailable = klaerrortouchidnotavailable,<span class="hljs-comment" style="color:rgb(147,161,161)"><span class="hljs-comment" style="color:rgb(147,161,161)">//device Touch ID not available, user not input</span></span>laerrortouchidnotenrolled = klaerrortouchidnotenrolled,}</code></pre><br><p><p></p></p><p><p><br></p></p><p><p><span style="color:rgb(47,47,47); font-family:‘lucida grande‘,‘lucida sans unicode‘,lucida,helvetica,‘Hiragino Sans GB‘,‘Microsoft YaHei‘,‘WenQuanYi Micro Hei‘,sans-serif; font-size:15px; text-align:justify; background-color:rgb(245,245,245)"><br></span></p></p><p><p>IOS Touch ID Usage details</p></p></span>