diff --git a/Sources/FaceLiveness/Views/Liveness/FaceLivenessDetectionView.swift b/Sources/FaceLiveness/Views/Liveness/FaceLivenessDetectionView.swift index f31d2390..309c3e81 100644 --- a/Sources/FaceLiveness/Views/Liveness/FaceLivenessDetectionView.swift +++ b/Sources/FaceLiveness/Views/Liveness/FaceLivenessDetectionView.swift @@ -82,8 +82,6 @@ public struct FaceLivenessDetectorView: View { isPreviewScreenEnabled: !disableStartView ) ) - - faceDetector.setFaceDetectionSessionConfigurationWrapper(configuration: viewModel) } init( @@ -142,6 +140,23 @@ public struct FaceLivenessDetectorView: View { } catch { throw FaceLivenessDetectionError.accessDenied } + + DispatchQueue.main.async { + if let faceDetector = viewModel.faceDetector as? FaceDetectorShortRange.Model { + faceDetector.setFaceDetectionSessionConfigurationWrapper(configuration: viewModel) + } + } + } + } + .onReceive(viewModel.$livenessState) { output in + switch output.state { + case .encounteredUnrecoverableError(let error): + let closeCode = error.webSocketCloseCode ?? .normalClosure + viewModel.livenessService?.closeSocket(with: closeCode) + isPresented = false + onCompletion(.failure(mapError(error))) + default: + break } } case .awaitingLivenessSession(let challenge):