Skip to content

手势密码解锁和 TouchID (指纹) / FaceID(面容) 解锁,代码简洁高效。(Gesture passcode unlocking and TouchID (fingerprint) / FaceID (facial features) unlocking.)

License

Notifications You must be signed in to change notification settings

itenfay/DYFAuthIDAndGestureLock

Repository files navigation

如果能帮助到你,请你给一颗星,谢谢!(If this can help you, please give it a star. Thanks!)

DYFAuthIDAndGestureLock

手势密码解锁和 TouchID (指纹) / FaceID(面容) 解锁,代码简洁高效。(Gesture passcode unlocking and TouchID (fingerprint) / FaceID (facial features) unlocking, its code is concise and efficient.)

License MIT  CocoaPods  CocoaPods 

Group (ID:614799921)

Installation

Using CocoaPods:

pod 'DYFAuthIDAndGestureLock'

Or

pod 'DYFAuthIDAndGestureLock', '~> 1.1.1'

Preview

Usage

  • 添加Face ID隐私 (Add Privacy)
<key>NSFaceIDUsageDescription</key>
<string>验证Face ID,是否允许App访问?</string>
  • 导入头文件 (Import Header)
#import "DYFAppLock.h"
  • 手势密码和TouchID/FaceID设置 (Gesture Passcode and TouchID/FaceID Settings)

支持push和模态两种场景过渡 (Supporting push or modal transition)

- (IBAction)settingsAction:(id)sender {
    static BOOL pushOrPresent = YES;

    DYFAuthIDAndGestureLockSettingsController *vc = [[DYFAuthIDAndGestureLockSettingsController alloc] init];
    if (pushOrPresent) {
        [self.navigationController pushViewController:vc animated:YES];
    } else {
        // When presents view controller, please add navigation controller.
        UINavigationController *nc = [[UINavigationController alloc] initWithRootViewController:vc];
        [self presentViewController:nc animated:YES completion:NULL];
    }

    pushOrPresent = !pushOrPresent;
}
  • 验证 (Authentication)
- (void)executeAuthentication {
    BOOL isAuthIDOpen      = [DYFSecurityHelper authIDOpen];
    BOOL isGestureCodeOpen = [DYFSecurityHelper gestureCodeOpen];
    if (!isAuthIDOpen && !isGestureCodeOpen) {
        return;
    }

    DYFAuthenticationType type = DYFAuthenticationTypeGesture;
    if (isAuthIDOpen) {
        type = DYFAuthenticationTypeAuthID;
    }

    DYFAuthenticationView *authView = [[DYFAuthenticationView alloc] initWithFrame:[UIScreen mainScreen].bounds authenticationType:type];
    authView.avatarImage = [UIImage imageNamed:@"cat49334.jpg"];
    [authView show];

    [authView authenticateWithCompletion:^(BOOL success) {
        if (success) {
            // 进行相应的操作
            NSLog(@"验证成功");
        }
    }];

    [authView loginOtherAccountWithCompletion:^{
        // 进行其他账户登录操作
        NSLog(@"登录其他账户");
    }];
}

Sample

About

手势密码解锁和 TouchID (指纹) / FaceID(面容) 解锁,代码简洁高效。(Gesture passcode unlocking and TouchID (fingerprint) / FaceID (facial features) unlocking.)

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published