UIAlertView*alert=[[UIAlertViewalloc]initWithTitle:@""message:@""delegate:selfcancelButtonTitle:@"Okay"otherButtonTitles:nil,nil];LAContext*myContext=[[LAContextalloc]init];NSError*authError=nil;NSString*myLocalizedReasonString=@"Restricted Area!";if([myContextcanEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometricserror:&authError]){[myContextevaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometricslocalizedReason:myLocalizedReasonStringreply:^(BOOLsuccess,NSError*error){if(success){// User authenticated successfully, take appropriate actionalert.title=@"Success";alert.message=@"You have access to private content!";[alertshow];}else{// User did not authenticate successfully, look at error and take appropriate actionalert.title=@"Fail";switch(error.code){caseLAErrorUserCancel:
alert.message=@"Authentication Cancelled";break;caseLAErrorAuthenticationFailed:
alert.message=@"Authentication Failed";break;caseLAErrorPasscodeNotSet:
alert.message=@"Passcode is not set";break;caseLAErrorSystemCancel:
alert.message=@"System cancelled authentication";break;caseLAErrorUserFallback:
alert.message=@"You chosed to try password";break;default:alert.message=@"You cannot access to private content!";break;}[alertshow];}}];}else{// Could not evaluate policy; look at authError and present an appropriate message to useralert.title=@"Warning";if(authError.code==LAErrorTouchIDNotEnrolled){alert.message=@"You do not have any fingerprints enrolled!";}elseif(authError.code==LAErrorTouchIDNotAvailable){alert.message=@"Your device does not support TouchID authentication!";}elseif(authError.code==LAErrorPasscodeNotSet){alert.message=@"Your passcode has not been set";}[alertshow];}