欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

IOS 指紋識別兩種方式詳解及實例

 更新時間:2017年06月21日 15:10:51   作者:IOS_Mainstay  
這篇文章主要介紹了IOS 指紋識別兩種方式詳解及實例的相關(guān)資料,需要的朋友可以參考下

IOS 指紋識別兩種方式詳解及實例

首先引入類名:

#import <LocalAuthentication/LocalAuthentication.h>

然后在實現(xiàn)指紋識別的地方放入如下代碼:

方式一:

LAContext *lacontext = [[LAContext alloc]init];
  // 判斷設(shè)備是否支持指紋識別
  BOOL isSupport = [lacontext canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:NULL];
  if(!isSupport)
  {
    NSLog(@"不支持!");
    return;
  }
  [lacontext evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics localizedReason:@"請按下手印" reply:^(BOOL success, NSError *error) {
    if(success)
    {
      NSLog(@"成功后,處理接下來的邏輯");
    }
  }];

iPhone 5s推出指紋識別, 在 iOS 8.0 蘋果開放了指紋識別的 SDK

最重要的應(yīng)用領(lǐng)域是支付

方式二:

if ([UIDevice currentDevice].systemVersion.floatValue < 8.0) {
    NSLog(@"不支持");
    return;
  }

  LAContext *ctx = [[LAContext alloc] init];
  // 判斷設(shè)備是否支持指紋識別
  if ([ctx canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:NULL]) {
    NSLog(@"支持");
    // 輸入指紋,異步
    // 提示:指紋識別只是判斷當(dāng)前用戶是否是手機(jī)的主人!程序原本的邏輯不會受到任何的干擾!
    [ctx evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics localizedReason:@"指紋登錄" reply:^(BOOL success, NSError *error) {
      if (success) {
        // 登錄成功
        // TODO
        NSLog(@"登陸成功");
      }
    }];
  } else {
    NSLog(@"不支持");
  }

感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!

相關(guān)文章

最新評論