Skip to content

Commit 151ceb0

Browse files
authored
chore: cleanup hostapp with additional logging (#38)
1 parent c356e05 commit 151ceb0

File tree

4 files changed

+19
-43
lines changed

4 files changed

+19
-43
lines changed

HostApp/HostApp.xcodeproj/project.pbxproj

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10-
73B461192A0A9B9F0085B8F8 /* AmplifyConfiguration in Resources */ = {isa = PBXBuildFile; fileRef = 73B461182A0A9B9F0085B8F8 /* AmplifyConfiguration */; };
1110
90236C77299D6D41009FD1A7 /* HostAppApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 90236C76299D6D40009FD1A7 /* HostAppApp.swift */; };
1211
90493F822992D64000CFE674 /* LivenessResult.swift in Sources */ = {isa = PBXBuildFile; fileRef = 90493F812992D64000CFE674 /* LivenessResult.swift */; };
1312
904CC73D2996E650002E0753 /* RootView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 904CC73C2996E650002E0753 /* RootView.swift */; };
@@ -53,7 +52,6 @@
5352
/* End PBXContainerItemProxy section */
5453

5554
/* Begin PBXFileReference section */
56-
73B461182A0A9B9F0085B8F8 /* AmplifyConfiguration */ = {isa = PBXFileReference; lastKnownFileType = folder; path = AmplifyConfiguration; sourceTree = "<group>"; };
5755
900129D4298ACA9100AE3524 /* HostApp.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = HostApp.entitlements; sourceTree = "<group>"; };
5856
90236C76299D6D40009FD1A7 /* HostAppApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HostAppApp.swift; sourceTree = "<group>"; };
5957
90493F812992D64000CFE674 /* LivenessResult.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LivenessResult.swift; sourceTree = "<group>"; };
@@ -141,7 +139,6 @@
141139
9070FFA2285112B4009867D5 /* HostApp */ = {
142140
isa = PBXGroup;
143141
children = (
144-
73B461182A0A9B9F0085B8F8 /* AmplifyConfiguration */,
145142
90FDF2A3299BDF340002CE7D /* Model */,
146143
90493FB0299577FE00CFE674 /* Info.plist */,
147144
900129D4298ACA9100AE3524 /* HostApp.entitlements */,
@@ -323,7 +320,6 @@
323320
buildActionMask = 2147483647;
324321
files = (
325322
9070FFAB285112B5009867D5 /* Preview Assets.xcassets in Resources */,
326-
73B461192A0A9B9F0085B8F8 /* AmplifyConfiguration in Resources */,
327323
9070FFA8285112B5009867D5 /* Assets.xcassets in Resources */,
328324
);
329325
runOnlyForDeploymentPostprocessing = 0;

HostApp/HostApp/AmplifyConfiguration/amplifyconfiguration.json

Lines changed: 0 additions & 30 deletions
This file was deleted.

HostApp/HostApp/Views/StartSessionViewModel.swift

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,15 @@ class StartSessionViewModel: ObservableObject {
1919
func setup() {
2020
Task { @MainActor in
2121
presentationState = .loading
22-
let session = try await Amplify.Auth.fetchAuthSession()
23-
presentationState = session.isSignedIn
24-
? .signedIn(action: signOut)
25-
: .signedOut(action: signIn)
22+
do {
23+
let session = try await Amplify.Auth.fetchAuthSession()
24+
presentationState = session.isSignedIn
25+
? .signedIn(action: signOut)
26+
: .signedOut(action: signIn)
27+
} catch {
28+
print("Error fetching auth session", error)
29+
}
30+
2631
}
2732
}
2833

@@ -50,12 +55,15 @@ class StartSessionViewModel: ObservableObject {
5055
func signIn() {
5156
Task { @MainActor in
5257
presentationState = .loading
53-
let signInResult = try await Amplify.Auth.signInWithWebUI(
54-
presentationAnchor: window
55-
)
56-
if signInResult.isSignedIn {
57-
presentationState = .signedIn(action: signOut)
58+
do {
59+
let signInResult = try await Amplify.Auth.signInWithWebUI(presentationAnchor: window)
60+
if signInResult.isSignedIn {
61+
presentationState = .signedIn(action: signOut)
62+
}
63+
} catch {
64+
print("Error signing in with web UI", error)
5865
}
66+
5967
}
6068
}
6169

HostApp/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ More information on setting up and using the FaceLivenessDetector is in the [Amp
1010

1111
## Running the App
1212

13+
Prerequisite: The host app requires backend resources to be configured with Amplify Auth category for authentication and Amplify API for starting/creating Liveness sessions.
14+
1315
1. Install Xcode version 12.0 or higher
1416
2. clone the Amplify UI Swift Liveness repository:
1517
```

0 commit comments

Comments
 (0)