iOS Touch ID使用
- Swift:
import LocalAuthentication |
var context = LAContext() |
OC
#import <LocalAuthentication/LocalAuthentication.h>
LAContext *context; (nonatomic,strong)
- (IBAction)buttonClick:(id)sender {
NSError *error;
if ([self.context canEvaluatePolicy:LAPolicyDeviceOwnerAuthentication error:&error]) {
[self.context evaluatePolicy:LAPolicyDeviceOwnerAuthentication localizedReason:@"Cancel" reply:^(BOOL success, NSError * _Nullable error) {
if (success) {
dispatch_sync(dispatch_get_main_queue(), ^{
/// do Something
});
}else{
NSLog(@"%@", error.localizedDescription);
}
}];
}else{
NSLog(@"%@", error.localizedDescription);
}
}
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 码行!
评论
ValineDisqus