没有密码功能的 TouchId

TouchId without Passcode feature

我需要我的应用程序使用 TouchId 登录,但我不希望用户 select 或回退到密码选项。换句话说,我想隐藏下图中的 'Enter Password' 标签。谢谢

据我所知,没有办法隐藏密码选项。尽管您可以使用设备密码作为后备。

请注意,术语“密码”和“密码”在 TouchID 集成中指的是不同的东西。

“密码”用于 LocalAuthentication 方法,用于集成 TouchID 并将应用程序密码作为后备方法。

虽然“密码”指的是解锁设备和在应用程序中验证购买的密码store.To使用该方法,您必须将一些信息存储到设备的钥匙串中并通过 Touch ID 身份验证检索它。

详细了解这两种方法here

iOS 9 编辑

在此的基础上,iOS9提供了一个隐藏密码选项的新选项。

For iOS 9, two new policies have been added that do not fallback to passcode. These policies are kSecAccessControlTouchIDAny and kSecAccessControlTouchIDCurrentSet

答案是“”。您可以隐藏"Enter password"...

试试下面的代码片段,

var LocalAuthentication = LAContext()

LocalAuthentication.localizedFallbackTitle = ""  // Add this line 

if LocalAuthentication.canEvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, error: &errorMsg){

在检查策略之前添加此行....

LocalAuthentication.localizedFallbackTitle = ""

希望这对您有所帮助..

根据 LocalAuthentication.LAContext 中的文档:

/// Fallback button title.
/// @discussion Allows fallback button title customization. A default title "Enter Password" is used when
///             this property is left nil. If set to empty string, the button will be hidden.
open var localizedFallbackTitle: String?