gpt4 book ai didi

ios - 如何禁用每次登录应用程序时出现 "touch ID activated"警报?

转载 作者:行者123 更新时间:2023-11-30 13:13:24 25 4
gpt4 key购买 nike

我的应用程序中目前有 touchID,并且目前工作正常。每次登录时都会弹出“touchID已激活”警报,这有点烦人。有没有办法更改它,使其仅在第一次登录时弹出,不再弹出?这是我的触摸 ID 代码,我在登录屏幕的 viewDidLoad 中调用 checkIfTouchIDActivated() :

 // MARK: TouchID

//Create a authentication context
let authenticationContext = LAContext()
var error:NSError?


//Check if the device has a fingerprint sensor, if not, dismiss
func checkIfTouchIDActivated () {

guard authenticationContext.canEvaluatePolicy(.DeviceOwnerAuthenticationWithBiometrics, error: &error) else {
print("TouchID not detected")
return
}
print("TouchID detected")

//Check the fingerprint
authenticationContext.evaluatePolicy(
.DeviceOwnerAuthenticationWithBiometrics,
localizedReason: "TouchID activated",
reply: { [unowned self] (success, error) -> Void in

//fingerprint has been recognized
if( success ){

self.loginButtonPressed(self)

}else {

// Check if there is an error
if let error = error {

let message = self.touchID.errorMessageForLAErrorCode(error.code)
self.showAlertViewAfterEvaluatingPolicyWithMessage(message)

}

}

})
}

最佳答案

您已将“TouchID 已激活” 作为localizedReason。如果您不想向用户显示您为什么要对其进行身份验证,只需给出 "" 即可。它通常类似于“您是设备所有者吗?”“使用您的 touch-ID 登录”,指示您请求 touch 的原因-id 来自用户的身份验证。

关于ios - 如何禁用每次登录应用程序时出现 "touch ID activated"警报?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38489791/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com