I guess what I'm saying with that comment (not actually in the code) is that line 39 is never getting executed. I can confirm with the backend API. So no statusCode either. Here is my code for the biometrics prompt:
func promptTouchOrFaceID() {
//create context for touch auth
let authenticationContext = LAContext()
var error: NSError?
authenticationContext.localizedFallbackTitle = ""
let biometricType = authenticationContext.biometricType
//check if the device has a fingerprint sensor, exit if not
guard authenticationContext.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: &error) else {
let title = "Error"
var message = ""
switch biometricType {
case .faceID:
message = "This device does not have a FaceID sensor or the sensor is not enabled."
case .touchID:
message = "This device does not have a TouchID sensor or the sensor is not enabled."
case .none:
message = "This device does not have any sensors to use TouchID or FaceID"
}
AlertService.showAlert(on: self, title: title, message: message)
UserDefaults.standard.set("False", forKey: UserDefaultsKeys.usesBiometrics)
removeLoadingSpinner()
return
}
authenticationContext.evaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, localizedReason: "Please use your fingerprint to authenticate.", reply: { [unowned self] (success, error) - Void in
if (success) {
//fingerprint recognized, set this possible and go to view controller
OperationQueue.main.addOperation({ () - Void in
self.fillInUserDetails()
self.login_now(username:self.tfUsername.text!, password: self.userDefaults.string(forKey: UserDefaultsKeys.password)!, customer: self.tfCustomerID.text!)
})
}
})
}
On line 22 I guess this is not a main dispatch, but wouldn't this cause a problem under normal use too? I am running on my own device and with a fresh install I get the correct prompt to use face id. I'm really suspicious of the UserDefaults since this happens only when the app isn't run for a long time.
Thanks
Topic:
Programming Languages
SubTopic:
Swift
Tags: