我已经为我的应用程序安全目的集成了LocalAuthentication,它一直支持基于"Touch Id"的支持.但是现在,苹果最近还增加了"基于身份识别"的身份验证.
如何检查设备支持哪种类型的身份验证.触摸ID或面部ID?
无论在Device的密码和touchId设置中配置了什么设置,LAContext始终都不返回任何设置.它只是给我一个警告而不是例外.
它只能在iOS11.1测试版的XCode 9.1 Beta中工作:
我想知道LAContext来自LocalAuthentication框架的实例的生命周期在iOS 8中是怎样的.
在iOS 9及更高版本中,有invalidate一种手动使当前上下文无效的方法.如果我没有使用该方法,则LAContext实例仍将处于活动状态并存储评估状态.可以说我可以在使用后简单地将其释放/释放,但我需要跨功能的实例来执行其他操作,例如验证其可用性以及invalidate在VC的不同点启用该方法.这也发生在iOS 8上吗?我会问Apple,因为文档没有澄清这一点,但我想事先找出更多的想法.
感谢大家!
我需要在 flutter 应用程序内实现 Face ID(生物识别)身份验证。我正在使用 flutter 包“local_auth”v1.1.6(https://pub.dev/packages/local_auth)。但是,当在所需设备上运行时,面部验证选项在应用程序中不可用。
我正在使用以下函数,该函数在按下按钮时运行:
Future<bool> authenticate() async {
try {
final canCheckBiometrics = await _auth.canCheckBiometrics;
print('canCheckBiometrics: ');
print(canCheckBiometrics);
final availableBiometrics = await _auth.getAvailableBiometrics();
print('getAvailableBiometrics: ');
print(availableBiometrics);
return await _auth.authenticate(
localizedReason: 'Authenticate',
biometricOnly: true,
);
} on PlatformException catch (e) {
print(e);
rethrow;
}
Run Code Online (Sandbox Code Playgroud)
}
但是,面部身份验证从未显示为可用的身份验证选项,即使它被列为“可用的生物识别”:
I/flutter ( 4816): canCheckBiometrics:
I/flutter ( 4816): true
I/flutter ( 4816): getAvailableBiometrics:
I/flutter ( 4816): [BiometricType.fingerprint, BiometricType.face]
Run Code Online (Sandbox Code Playgroud)
如果设备上同时设置了指纹和面部,则指纹将显示为唯一可用的身份验证选项。如果仅设置了face,则local_auth库会抛出“NotEnrolled”异常(如果未设置任何方法,则相同):
I/flutter ( 4816): canCheckBiometrics:
I/flutter ( 4816): true
I/flutter ( 4816): …Run Code Online (Sandbox Code Playgroud) 我编写了以下代码片段
if ([contextNew canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&error])
{
[contextNew evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics localizedReason:NSLocalizedString(@"",nil) reply:^(BOOL success, NSError *error)
{
if(success)
{
}
else
{
}
}
}
Run Code Online (Sandbox Code Playgroud)
验证面部后它进入成功阻止.我想处理面部识别权限警报.我想获得面部ID的Yes或permission permission方法.因为我们得到像AVAuthorizationStatus的相机

我已经浏览了local_auth包,它工作正常,但没有选项可以使用密码或引脚进行身份验证.帮助赞赏!
String _authorized = 'Not Authorized';//Start
Future<Null> _authenticate() async {
final LocalAuthentication auth = new LocalAuthentication();
bool authenticated = false;
try {
authenticated = await auth.authenticateWithBiometrics(
localizedReason: 'Scan your fingerprint to authenticate',
useErrorDialogs: true,
stickyAuth: false);
authenticated = await auth.authenticateWithBiometrics(localizedReason: 'Authenticate');
} on PlatformException catch (e) {
print(e);
}
if (!mounted) return;
setState(() {
_authorized = authenticated ? 'Authorized' : 'Not Authorized';
});
}//End
Run Code Online (Sandbox Code Playgroud)
所以这是示例代码,您可以使用生物识别身份验证,但是指纹中还存在默认的Pin/Password身份验证.
我继承了一个代码库,其中包含以下类,提供对 Face/Touch ID 的支持。
预期的行为是,在 Face/Touch ID 成功后,用户就会登录。这是有效的。
但是,如果用户未能通过 Face ID 并选择输入密码,则一旦调用完成处理程序,他们就会退出。我相信选择使用密码会触发
else {
self.authState = .unauthenticated
completion(.unauthenticated)
}
Run Code Online (Sandbox Code Playgroud)
如何触发密码提示?我应该使用它来创建第二个策略LAPolicy.deviceOwnerAuthentication并对其进行评估吗?
import LocalAuthentication
public enum AuthenticationState {
case unknown
case authenticated
case unauthenticated
public func isAuthenticated() -> Bool {
return self == .authenticated
}
}
public protocol TouchIDAuthenticatorType {
var authState: AuthenticationState { get }
func authenticate(reason: String, completion: @escaping (AuthenticationState) -> Void) -> Void
func removeAuthentication() -> Void
}
public protocol LAContextType: class {
func canEvaluatePolicy(_ policy: LAPolicy, …Run Code Online (Sandbox Code Playgroud) 我已经在我的项目中成功实施了"In App Purchase",现在我正在尝试实施"Touch Id"来购买产品,除了要求"登录iTunes"弹出窗口.在我的代码中,它一个接一个地询问"touch id"和"登录iTunes"弹出窗口,为什么这个连接两件事我只想"触摸id"来购买产品.我已经去了IAP 你如何在iOS应用程序中添加应用内购买?和Touch ID 如何为我的IAP集成Touch ID?但没有得到正确的方法来实现IAP的触摸ID.这是我添加的代码,
这可以通过代码实现,也可以在从应用商店购买产品时显示苹果.检查上面的快照,
#import <LocalAuthentication/LocalAuthentication.h>
-(void) localAunthentication
{
//LocalAuthentication
LAContext *authContext = [[LAContext alloc] init];
NSError *authError = nil;
NSString *authLocalizedReasonString = @"Please aunthenticate to proceed";
if ([authContext canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&authError])
{
[authContext evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics
localizedReason:authLocalizedReasonString
reply:^(BOOL success, NSError *error)
{
if (success)
{
// Allocated here for succinctness.
NSOperationQueue *operationQueue = [[NSOperationQueue alloc] init];
[operationQueue addOperationWithBlock: ^
{
}];
}
else
{
switch (error.code)
{
case LAErrorAuthenticationFailed:
//Authentication Failed
break;
case LAErrorUserCancel: …Run Code Online (Sandbox Code Playgroud) objective-c in-app-purchase ios touch-id localauthentication
我想使用TouchID验证我的应用程序,验证成功.如果TouchID不匹配,则会打开"再试一次"警报,并在该警报中输入"密码"选项.如果用户选择该选项,则应显示系统密码验证,但我该怎么办呢?

在这里分享我的代码:
func touchIDAuthentication() {
let context = LAContext() //1
var error:NSError?
guard context.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: &error) else {
showAlertViewIfNoBiometricSensorHasBeenDetected()
return
}
if context.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: &errorPointer) {
context.evaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, localizedReason: reason, reply: { (success, error) in
if success {
DispatchQueue.main.async {
print("Authentication was successful")
}
}else {
DispatchQueue.main.async {
self.displayErrorMessage(error: error as! LAError )
print("Authentication was error")
}
}
})
}else {
self.showAlertWith(title: "Error", message: (errorPointer?.localizedDescription)!)
}
}
func displayErrorMessage(error:LAError) {
var message = ""
switch error.code {
case LAError.authenticationFailed:
message = …Run Code Online (Sandbox Code Playgroud) 在我们的应用程序中,用户必须注册到设备biometry才能使用它进行身份验证.注册文本和法律注释是根据相关的生物统计学(注册到触摸ID或注册到面部ID)据我发现,生物测定类型可以通过LAContext获得,但如果用户拒绝使用生物测量,那么上下文返回biometryType = .none
任何其他要求屏幕尺寸和与iPhone X(坏的坏代码)比较的想法?
static fileprivate var biometryType: DSLocalAuthenticationBiometryType {
let context = LAContext()
var error: NSError?
let _ = context.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: &error)
if #available(iOS 11.0, *) {
return context.biometryType == .typeFaceID ? .typeFaceID : .none
}
else {
return .none
}
}
Run Code Online (Sandbox Code Playgroud)
谢谢
我想将应用程序的登录信息从用户名和密码替换为颤动中的指纹,因此用户在获得成功的指纹后,将在应用程序中看到他的信息(此信息从服务器发送)。我如何管理我想要一些东西使该指纹与该用户连接以从服务器获取正确的数据?我使用local_auth进行指纹身份验证,但我不知道告诉服务器该指纹与该用户关联。
我读了一些类似的东西来处理这个问题:
有没有更好的方法?
ios ×7
face-id ×6
touch-id ×5
flutter ×3
biometrics ×2
ios11 ×2
lacontext ×2
objective-c ×2
swift ×2
android ×1
cocoa-touch ×1
dart ×1
fingerprint ×1
iphone-x ×1
lifetime ×1