• iOS8使用TouchID


    iOS8新增了LocalAuthentication框架,用于TouchID的授权使用。亲測,眼下须要用户的设备支持指纹识别并已设置锁屏,并且实际測试过程中反馈比較慢。不能直接跟第三方账号password绑定,假设须要实现第三方应用直接指纹识别登录,须要在本地存储账号信息,指纹识别通过之后再从本地读取账号信息登录。总之。眼下的指纹识别是跟设备、设备锁屏password绑定的。

    測试代码:

    ///使用TouchID
    -(void)usingTouchID
    {
        LAContext *myContext = [[[LAContext alloc] init] autorelease];
        NSError *authError = nil;
        NSString *myLocalizedReasonString = @"用于指纹登录";
        if ([myContext canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&authError]) {
            [myContext evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics
                      localizedReason:myLocalizedReasonString
                                reply:^(BOOL success, NSError *error) {
                                    if (success) {
                                        // User authenticated successfully, take appropriate action
                                        NSLog(@"成功");
                                        UIAlertView *alertView = [[[UIAlertView alloc] initWithTitle:@"Suceess" message:@"已通过指纹识别。" delegate:self cancelButtonTitle:nil otherButtonTitles:@"OK", nil] autorelease];
                                        [alertView show];
                                    } else {
                                        // User did not authenticate successfully, look at error and take appropriate action
                                        NSLog(@"fail with error:%@",error);
                                        UIAlertView *alertView = [[[UIAlertView alloc] initWithTitle:@"Failed" message:[error localizedDescription] delegate:self cancelButtonTitle:nil otherButtonTitles:@"OK", nil] autorelease];
                                        [alertView show];
                                    }
                                }];
        } else {
            // Could not evaluate policy; look at authError and present an appropriate message to user
            NSLog(@"auth with error:%@",authError);
            UIAlertView *alertView = [[[UIAlertView alloc] initWithTitle:@"Failed" message:[authError localizedDescription] delegate:self cancelButtonTitle:nil otherButtonTitles:@"OK", nil] autorelease];
            [alertView show];
        }
    }
    



  • 相关阅读:
    互操作
    Rx基础
    数据流块基础
    C# 一个帮您理解回调函数的例子(新手必看)
    C# 多线程之通过Timer开启线程的例子
    C# 利用委托事件进行窗体间的传值(新手必看)
    C#XML文件操作随笔
    C# 委托学习笔记
    c# 关于抓取网页源码后中文显示乱码的原因分析和解决方法
    c# 异步编程 使用回调函数例子
  • 原文地址:https://www.cnblogs.com/brucemengbm/p/6848496.html
Copyright © 2020-2023  润新知