Skip to content

Commit

Permalink
chore(ux): update handling of camera permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
phantumcode committed Nov 15, 2023
1 parent e3cab2c commit fec3833
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ public struct FaceLivenessDetectorView: View {
onCompletion(.success(()))
case .encounteredUnrecoverableError(let error):
let closeCode = error.webSocketCloseCode ?? .normalClosure
viewModel.livenessService.closeSocket(with: closeCode)
viewModel.livenessService?.closeSocket(with: closeCode)
isPresented = false
onCompletion(.failure(mapError(error)))
default:
Expand Down Expand Up @@ -210,10 +210,7 @@ public struct FaceLivenessDetectorView: View {
for: .video,
completionHandler: { accessGranted in
guard accessGranted == true else { return }
displayState = .displayingLiveness
DispatchQueue.main.async {
UIScreen.main.brightness = 1.0
}
displayState = .awaitingLivenessSession
}
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class FaceLivenessDetectionViewModel: ObservableObject {
var closeButtonAction: () -> Void
let videoChunker: VideoChunker
let sessionID: String
var livenessService: LivenessService!
var livenessService: LivenessService?
let faceDetector: FaceDetector
let faceInOvalMatching: FaceInOvalMatching
let challengeID: String = UUID().uuidString
Expand Down Expand Up @@ -90,7 +90,7 @@ class FaceLivenessDetectionViewModel: ObservableObject {
}

func registerServiceEvents() {
livenessService.register(onComplete: { [weak self] reason in
livenessService?.register(onComplete: { [weak self] reason in
self?.stopRecording()

switch reason {
Expand All @@ -106,7 +106,7 @@ class FaceLivenessDetectionViewModel: ObservableObject {
}
})

livenessService.register(
livenessService?.register(
listener: { [weak self] _sessionConfiguration in
self?.sessionConfiguration = _sessionConfiguration
},
Expand Down Expand Up @@ -174,7 +174,7 @@ class FaceLivenessDetectionViewModel: ObservableObject {

func initializeLivenessStream() {
do {
try livenessService.initializeLivenessStream(
try livenessService?.initializeLivenessStream(
withSessionID: sessionID,
userAgent: UserAgentValues.standard().userAgentString
)
Expand All @@ -197,7 +197,7 @@ class FaceLivenessDetectionViewModel: ObservableObject {
)

do {
try livenessService.send(
try livenessService?.send(
.freshness(event: freshnessEvent),
eventDate: { .init() }
)
Expand Down Expand Up @@ -238,7 +238,7 @@ class FaceLivenessDetectionViewModel: ObservableObject {
initialClientEvent = _initialClientEvent

do {
try livenessService.send(
try livenessService?.send(
.initialFaceDetected(event: _initialClientEvent),
eventDate: { .init() }
)
Expand Down Expand Up @@ -270,7 +270,7 @@ class FaceLivenessDetectionViewModel: ObservableObject {
)

do {
try livenessService.send(
try livenessService?.send(
.final(event: finalClientEvent),
eventDate: { .init() }
)
Expand All @@ -296,7 +296,7 @@ class FaceLivenessDetectionViewModel: ObservableObject {
let videoEvent = VideoEvent.init(chunk: data, timestamp: timestamp)

do {
try livenessService.send(
try livenessService?.send(
.video(event: videoEvent),
eventDate: { eventDate }
)
Expand Down Expand Up @@ -335,7 +335,7 @@ class FaceLivenessDetectionViewModel: ObservableObject {
let videoEvent = VideoEvent.init(chunk: data, timestamp: timestamp)

do {
try livenessService.send(
try livenessService?.send(
.video(event: videoEvent),
eventDate: { eventDate }
)
Expand Down

0 comments on commit fec3833

Please sign in to comment.