mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-05 03:48:27 +00:00
Add support for Face ID/Touch ID to app lock. (#1966)
* Fix biometrics with low grace period and backgrounding before unlocked. * Trigger permissions alert when enabling Face ID.
This commit is contained in:
+27
-6
@@ -39,13 +39,34 @@ class AppLockSetupBiometricsScreenViewModel: AppLockSetupBiometricsScreenViewMod
|
||||
|
||||
switch viewAction {
|
||||
case .allow:
|
||||
MXLog.info("Enable biometric unlock.")
|
||||
appLockService.biometricUnlockEnabled = true
|
||||
actionsSubject.send(.continue)
|
||||
Task { await enableBiometricUnlock() }
|
||||
case .skip:
|
||||
MXLog.info("Disable biometric unlock.")
|
||||
appLockService.biometricUnlockEnabled = false
|
||||
actionsSubject.send(.continue)
|
||||
disableBiometricUnlock()
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Private
|
||||
|
||||
private func enableBiometricUnlock() async {
|
||||
guard case .success = appLockService.enableBiometricUnlock() else {
|
||||
MXLog.error("Enabling biometric unlock failed.")
|
||||
return
|
||||
}
|
||||
MXLog.info("Biometric unlock enabled.")
|
||||
|
||||
// Attempt unlock to trigger Face ID permissions alert.
|
||||
if appLockService.biometryType == .faceID,
|
||||
await !appLockService.unlockWithBiometrics() {
|
||||
MXLog.info("Confirmation failed. Disabling biometric unlock.")
|
||||
appLockService.disableBiometricUnlock()
|
||||
}
|
||||
|
||||
actionsSubject.send(.continue)
|
||||
}
|
||||
|
||||
private func disableBiometricUnlock() {
|
||||
appLockService.disableBiometricUnlock()
|
||||
MXLog.info("Biometric unlock disabled.")
|
||||
actionsSubject.send(.continue)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user