- (void) Touchesbegan: (Nsset<uitouch *> *) touches withevent: (Uievent *)Event{ //1. Judging the system version if([Uidevice Currentdevice].systemversion.floatvalue >=8.0) { //can use fingerprint identification--5S later modelsLacontext *context =[[Lacontext alloc] init]; if([Context canevaluatepolicy:lapolicydeviceownerauthenticationwithbiometrics Error:nil]) {//can use//3. Start enabling fingerprint recognition//Localizedreason: The reason that is displayed on the interface, is generally used to prompt the user, why use this feature[Context Evaluatepolicy:lapolicydeviceownerauthenticationwithbiometrics Localizedreason:@"Please verify the fingerprint to turn on advanced hide feature"reply:^ (BOOL success, Nserror *_nullable Error) { //Judging whether it is successful if(Success) {//4. Fingerprint recognition when updating the UI, be aware that the main thread updateDispatch_sync (Dispatch_get_main_queue (), ^{[Self Createuialertcontroller:@"Validation Successful"]; }); } Else{Dispatch_sync (Dispatch_get_main_queue (),^{[Self Createuialertcontroller:@"validation Failed"]; }); } //Judging errors If you need to distinguish between different errors to prompt for, you must determine the error if(Error) {NSLog (@"error Code:%ld", Error.code); NSLog (@"Error:%@", Error.userinfo); } }]; } Else{NSLog (@"Sorry, this feature is only available for models above 5S"); } } Else{NSLog (@"Sorry, the system version is too low"); } }-(void) Createuialertcontroller: (nsstring*) title{Uialertcontroller* Alert =[uialertcontroller Alertcontrollerwithtitle:@"Tips"Message:title Preferredstyle:uialertcontrollerstylealert]; Uialertaction* Action =[uialertaction Actionwithtitle:@"Confirm"Style:uialertactionstyledefault handler:^ (Uialertaction *_nonnull Action) { }]; Uialertaction* Action1 =[uialertaction Actionwithtitle:@"Cancel"Style:uialertactionstylecancel handler:^ (Uialertaction *_nonnull Action) { }]; [Alert Addaction:action1]; [Alert addaction:action]; [Self Presentviewcontroller:alert animated:yes completion:nil];}
ios-fingerprint identification