Is it possible to cancel the TouchID alert dialog programmatically after the LAContext.evaluatePolicy
call? If yes: how?
In my case, I find out why it not working because the LAContext instance I try to invalidate() is not the same instance who I call evaluatePolicy().
So You need to make sure that all ViewControllers shared the same instance. swift 4
public class MyBiometryUtility: NSObject {
static private var sharedBiometry: MyBiometryUtility? = nil
var context: LAContext = LAContext()
@objc public static func sharedInstance() -> MyBiometryUtility{
if let sharedBiometry = sharedBiometry {
return sharedBiometry;
} else{
sharedBiometry = MyBiometryUtility()
return sharedBiometry!
}
}
public func tryBiometryAuth() { ... }
public func closeBiometryAuth() {... }
In SomeViewController.swift
func buttonTapped(sender: Any){
// show dialog.
MyBiometryUtility.sharedInstance().tryBiometryAuth()
}
func timerCountDown(){
// close dialog.
if tooLong() {
MyBiometryUtility.sharedInstance().closeBiometryAuth()
}
}