IOS (Personal privacy wallet call System TouchID fingerprint lock verification)

Source: Internet
Author: User

//

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.