苹果faceid使用swift4

来源:互联网 发布:淘宝 食品经营许可证 编辑:程序博客网 时间:2024/06/14 10:34


    func showAlert(title: String, message: String) {

        let okAction = AlertAction(title: OKTitle)
        let alertController = getAlertViewController(type: .alert, with: title, message: message, actions: [okAction], showCancel: false) { (button) in
        }
        present(alertController, animated: true, completion: nil)
    }
    
    func showLoginSucessAlert() {
        showAlert(title: "成功", message: "登陆成功(Login successful) ")
    }

//https://github.com/rushisangani/BiometricAuthentication/blob/master/BiometricAuthenticationExample/BiometricAuthenticationExample/ViewController.swift#L38

///https://github.com/MilanistaDev/AuthenticationTest


Face ID and Touch ID

Whenever possible, support biometric authentication. Face ID and Touch ID are secure, familiar authentication methods that people trust. If a user has enabled biometric authentication, you can assume they understand how it works, appreciate its convenience, and prefer to use it whenever possible. Bear in mind that people may choose to disable biometric authentication on their device, so your app should be prepared to handle this scenario.

Present people with a single way to authenticate. It's most intuitive when people don't have to choose how to authenticate. Just give them a single option, like Face ID. Offer alternatives, like asking for a username and password, as fallbacks only if the initial method fails.

Initiate authentication only in response to user action. An explicit action, like tapping a button, ensures that the user wants to authenticate. In the case of Face ID, it also increases the likelihood that the user is facing the camera.

Always identify the authentication method. A button for signing in to your app using Face ID, for example, should be titled "Sign In with Face ID" rather than "Sign In."

Reference authentication methods accurately. Don't reference Touch ID on a device that supports Face ID. Conversely, don't reference Face ID on a device that supports Touch ID. Check the device's capabilities and use the appropriate terminology. For developer guidance, see LABiometryType.

In general, avoid offering a setting for opting in to biometric authentication within your app. If biometric authentication is enabled at the system level, just assume the user wants to use it. If you implement an app-specific setting, the user may get into a state where biometric authentication appears to be enabled in your app when it's really disabled systemwide.

Don't use icons to identify system authentication features. When people see icons that look like the system's Touch ID (thumbprint) and Face ID icons, they think they're supposed to authenticate. Using icons to identify authentication features creates inconsistency and causes confusion, especially when the icons are colorized, displayed at a large size, and presented out of context.









































































原创粉丝点击