[英]How do I start monitor for finger prints using BiometricKit framework in ios 10 theos?
If you want to play around with the private BiometricKit framework on a jailbroken device I can't really help...如果你想在越狱设备上使用私有的 BiometricKit 框架,我真的无能为力......
If you're only interested in leveraging the TouchID functionality though, you only need to use the public LocalAuthentication framework.如果您只对利用 TouchID 功能感兴趣,则只需使用公共LocalAuthentication框架。
Here's a really basic implementation in Objective-C in a pretend MyViewController
, subclass of UIViewController
(You might eventually want to move the logic out of there):这是一个在 Objective-C 中的一个非常基本的实现,在一个假装的
MyViewController
, UIViewController
子类(你可能最终想要将逻辑移出那里):
#import "MyViewController.h"
@import LocalAuthentication;
@interface MyViewController ()
@property (nonatomic, strong) LAContext *localAuthContext;
@end
@implementation MyViewController
- (void)viewDidLoad {
[super viewDidLoad];
[self authenticateWithTouchID]; // Call this whenever TouchID authentication is required.
}
#pragma mark - TouchID Authentication
- (void)authenticateWithTouchID {
NSError *evaluationError;
if (![self.localAuthContext canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&evaluationError]) {
// TODO: Handle error case. (device with no TouchID capability)
NSLog(@"%@", evaluationError.localizedDescription);
} else {
[self.localAuthContext evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics
localizedReason:@"Authenticate using Touch ID"
reply:^(BOOL success, NSError *error) {
if (!success) {
// TODO: Handle error case. (failed TouchID authentication)
NSLog(@"%@", error.localizedDescription);
} else {
// TODO: Handle success case.
NSLog(@"TouchID authentication successful.");
}
}];
}
}
#pragma mark - Lazy Instantiation
- (LAContext *)localAuthContext
{
if (!_localAuthContext) {
_localAuthContext = [[LAContext alloc] init];
_localAuthContext.localizedFallbackTitle = @""; // Hides the "Enter Password" button. Comment out to allow the user to enter his device passcode as a fallback option.
}
return _localAuthContext;
}
@end
First make sure that you have a fingerprint set up on your device (Settings > Touch ID & Passcode > Fingerprints section).首先确保您在设备上设置了指纹(设置 > 触控 ID 和密码 > 指纹部分)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.