//
Viewcontroller.m
TouchID Fingerprint Verification
//
Created by Apple on 16/9/18.
copyright©2016 year Apple. All rights reserved.
//
#import "ViewController.h"
#import "HomeViewController.h"//The view controller to jump to after successful jump
#import <localauthentication/localauthentication.h>//Import the class library required for TouchID
#import <sys/utsname.h> // access to the class library required for basic information on the device
@interface viewcontroller ()
@end
@implementation Viewcontroller
-(void) viewdidload {
[Super viewdidload];
[self touchID];
}
-(void) Touchesbegan: (nsset<uitouch *> *) touches withevent: (uievent *) Event
{
// call TouchID will execute this method, there is a need to implement some additional functions
}
-(void) TouchID {
lacontext *context = [[lacontext alloc] init];
nserror *error = nil;
/// first step to determine if Touch ID is supported or if the machine has entered a fingerprint
if ([Context canevaluatepolicy:lapolicydeviceownerauthenticationwithbiometrics error: &error]) {
[Context EvaluatePolicy:lapolicydeviceownerauthenticationwithbiometrics localizedreason: @ " Please verify existing fingerprint " reply: ^ (BOOL success, nserror * _nullable error) {
if (error) {
NSLog(@ " verification failed "); //The system will automatically give the error prompt
}Else{
dispatch_async(dispatch_get_main_queue(), ^{
// fingerprint verification after successful jump
homeviewcontroller *home = [[homeviewcontroller alloc] init];
[self presentviewcontroller: Home animated:YES completion:nil];
});
}
}];
}Else {
// determine if the real machine is running
if (self. Issimulator) {
[[[uialertview alloc Initwithtitle:@ " hint " Span class= "S1" >message:@ " please test ~" delegate:nil Cancelbuttontitle:@ " good " otherbuttontitles:nil Span class= "S6" >nil show;
}Else{
[[[uialertview alloc Initwithtitle:@ " hint " Span class= "S1" >message:@ " not supported touch id~" Span class= "S7" > delegate:nil cancelbuttontitle:@ " good " otherbuttontitles:nil Span class= "S6" >nil show;
}
}
}
determine if the current device supports TouchID functionality
-(BOOL) issimulator{
struct utsname systemInfo;
uname(&systeminfo);
nsstring *devicemachine = [nsstring stringwithcstring: SystemInfo. Machine encoding:nsutf8stringencoding];
if ([Devicemachine isequaltostring:@ "i386"] | | [Devicemachine isequaltostring:@ "x86_64"]) {
return YES;
}
return NO;
}
-(void) didreceivememorywarning {
[Super didreceivememorywarning];
//Dispose of any resources, can be recreated.
}
@end
IOS (Personal privacy wallet call System TouchID fingerprint lock verification)