Skip to content

Commit

Permalink
chore: refactor session fit timeout from backend service (aws-amplify#46
Browse files Browse the repository at this point in the history
)

* refactor: get fit timeout from backend service

* chore: update version

* chore: update amplify swift dependency

* chore: refactor timeout

* chore: update amplify version

* chore: code cleanup
  • Loading branch information
phantumcode authored and devedup committed Sep 12, 2023
1 parent 116cf3e commit c845d22
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion HostApp/HostApp.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,7 @@
repositoryURL = "https://github.com/aws-amplify/amplify-ui-swift-liveness";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 1.0.0;
minimumVersion = 1.1.1;
};
};
9077AB3529E5D28900433155 /* XCRemoteSwiftPackageReference "amplify-swift" */ = {
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ let package = Package(
targets: ["FaceLiveness"]),
],
dependencies: [
.package(url: "https://github.com/aws-amplify/amplify-swift", from: "2.14.1")
.package(url: "https://github.com/aws-amplify/amplify-swift", from: "2.15.4")
],
targets: [
.target(
Expand Down
2 changes: 1 addition & 1 deletion Sources/FaceLiveness/Utilities/UserAgent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ struct UserAgentValues {
swiftVersion: Swift().version(),
unameMachine: Device.current.machine.replacingOccurrences(of: ",", with: "_"),
locale: Locale.current.identifier,
lib: "lib/amplify-ui-swift-face-liveness/1.1.0",
lib: "lib/amplify-ui-swift-face-liveness/1.1.1",
additionalMetadata: additionalMetadata
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import SwiftUI
@_spi(PredictionsFaceLiveness) import AWSPredictionsPlugin

fileprivate let initialFaceDistanceThreshold: CGFloat = 0.32
fileprivate let noFitTimeoutInterval: TimeInterval = 7

extension FaceLivenessDetectionViewModel: FaceDetectionResultHandler {
func process(newResult: FaceDetectionResult) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import AVFoundation
@_spi(PredictionsFaceLiveness) import AWSPredictionsPlugin

fileprivate let videoSize: CGSize = .init(width: 480, height: 640)
fileprivate let defaultNoFitTimeoutInterval: TimeInterval = 7

@MainActor
class FaceLivenessDetectionViewModel: ObservableObject {
Expand Down Expand Up @@ -41,6 +42,14 @@ class FaceLivenessDetectionViewModel: ObservableObject {
var faceMatchedTimestamp: UInt64?
var noFitStartTime: Date?

var noFitTimeoutInterval: TimeInterval {
if let sessionTimeoutMilliSec = sessionConfiguration?.ovalMatchChallenge.oval.ovalFitTimeout {
return TimeInterval(sessionTimeoutMilliSec/1_000)
} else {
return defaultNoFitTimeoutInterval
}
}

init(
faceDetector: FaceDetector,
faceInOvalMatching: FaceInOvalMatching,
Expand Down

0 comments on commit c845d22

Please sign in to comment.