//
获得当前设备的系统版本号
float version = [[UIDevice currentDevice] systemVersion].floatValue;
NSLog(@"%f",version);
if (version < 8.0) {
NSLog(@"请升级至最新系统!");
return;
}
// 如果系统版本号 > 8.0 ,还需要判断设备是否支持 TouchID
// 1.实例化指纹识别器
LAContext *context = [[LAContext alloc] init];
// 返回值: YES :说明当前设备支持指纹识别功能!
BOOL is_YES = [context canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:NULL];
if (!is_YES) {
NSLog(@"请您购买最新的苹果设备!");
}else
{
// 开启指纹识别
// reply :输入指纹之后的Block回调!
[context evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics localizedReason:@"请输入指纹" reply:^(BOOL success, NSError *error) {
// success :YES 标示指纹输入成功!
if (success) {
NSLog(@"指纹输入成功!");
NSLog(@"登陆成功!");
}else
{
NSLog(@"请洗手后再次输入!");
}
}];
}
float version = [[UIDevice currentDevice] systemVersion].floatValue;
NSLog(@"%f",version);
if (version < 8.0) {
NSLog(@"请升级至最新系统!");
return;
}
// 如果系统版本号 > 8.0 ,还需要判断设备是否支持 TouchID
// 1.实例化指纹识别器
LAContext *context = [[LAContext alloc] init];
// 返回值: YES :说明当前设备支持指纹识别功能!
BOOL is_YES = [context canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:NULL];
if (!is_YES) {
NSLog(@"请您购买最新的苹果设备!");
}else
{
// 开启指纹识别
// reply :输入指纹之后的Block回调!
[context evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics localizedReason:@"请输入指纹" reply:^(BOOL success, NSError *error) {
// success :YES 标示指纹输入成功!
if (success) {
NSLog(@"指纹输入成功!");
NSLog(@"登陆成功!");
}else
{
NSLog(@"请洗手后再次输入!");
}
}];
}
}
钥匙串访问:
NSString *username = @"zhangsan";
// 应用的唯一标识符!
NSString *str = [NSBundle mainBundle].bundleIdentifier;
// 从钥匙串中取出保存的密码
NSString *password = [SSKeychain passwordForService:str account:username];
NSLog(@"password:%@",password);
}
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
// 钥匙串访问! AES 256 本地数据存储安全: 密码/账号
// 钥匙串:不知道钥匙串存在说明地方!
// 在本地存储隐私数据的时候,不允许以明文的形式存储!
// 钥匙串的使用
// setPassword :需要保存的密码
// forService :应用的唯一标识符
// account: 账号
NSString *password = @"zhang";
NSString *username = @"zhangsan";
// 应用的唯一标识符!
NSString *str = [NSBundle mainBundle].bundleIdentifier;
// 将账号 username 的密码存入钥匙串中!
[SSKeychain setPassword:password forService:str account:username];