Skip to content

Commit 4e0fc17

Browse files
authored
chore: update sample app readme (#32)
1 parent 6c96cdd commit 4e0fc17

File tree

2 files changed

+111
-19
lines changed

2 files changed

+111
-19
lines changed

.gitignore

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,18 @@ DerivedData/
77
.swiftpm/config/registries.json
88
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
99
.netrc
10+
HostApp/amplify/
11+
HostApp/build/
12+
HostApp/dist/
13+
HostApp/node_modules/
14+
HostApp/generated-src/
15+
HostApp/aws-exports.js
16+
HostApp/.gitignore
17+
HostApp/awsconfiguration.json
18+
HostApp/amplifyconfiguration.json
19+
HostApp/amplifyconfiguration.dart
20+
HostApp/amplify-build-config.json
21+
HostApp/amplify-gradle-config.json
22+
HostApp/amplifytools.xcconfig
23+
HostApp/.secret-*
24+
HostApp/**.sample

HostApp/README.md

Lines changed: 96 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,31 +8,108 @@ Amplify UI FaceLivenessDetector provides a UI component for Amazon Rekognition F
88

99
More information on setting up and using the FaceLivenessDetector is in the [Amplify UI Face Liveness documentation](https://ui.docs.amplify.aws/swift/connected-components/liveness).
1010

11-
## Set Up
11+
## Running the App
1212

13-
This sample app depends on AWS Amplify library and assumes Amplify Auth and Amplify API are configured. You will need to either update the `amplifyconfiguration.json` with the missing configuration details or replace the placeholder file wit your `amplifyconfiguration.json` file. For additional details on configuring Amplify, see [Face Liveness documentation](https://ui.docs.amplify.aws/swift/connected-components/liveness#step-1-configure-amplify)
13+
1. Install Xcode version 12.0 or higher
14+
2. clone the Amplify UI Swift Liveness repository:
15+
```
16+
git clone https://github.com/aws-amplify/amplify-ui-swift-liveness.git
17+
```
18+
3. Change directory to `HostApp`
19+
```
20+
cd amplify-ui-swift-livenes/HostApp
21+
```
22+
4. Open HostApp.xcodeproj in Xcode
23+
24+
5. The sample app depends on a real device camera to capture videos. Build and deploy the app onto a real device.
1425

15-
To update the `amplifyconfiguration.json`:
16-
Edit the file with the appropriate credential provider Pool ID and Region.
26+
6. When the app is launch, click the Sign in button to sign up and then sign in.
27+
28+
7. Once signed in and authenticated, the "Create Liveness Session" is enabled. Click the button to generate and get a session id from your backend.
29+
30+
8. Once a session id is created, the Liveness Check screen is displayed. Follow the instructions and click on Begin Check button to begin liveness verification.
31+
32+
## Provision AWS Backend Resources
33+
34+
1. Follow the [instructions](https://docs.amplify.aws/start/getting-started/installation/q/integration/ios/) to sign up for an AWS account and set up the Amplify CLI.
35+
2. Initialize Amplify in the project by running the following command from the project directory:
36+
```
37+
amplify init
1738
```
18-
"Default": {
19-
"PoolId": "us-east-1:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
20-
"Region": "us-east-1"
21-
}
39+
Provide the responses shown after each of the following prompts.
2240
```
41+
? Enter a name for the project: `LivenessHostApp`
42+
The following configuration will be applied:
2343
24-
This sample app assumes that the session id is fetched from an API REST endpoint, update the Amplify API Category section of the `amplifyconfiguration.json` file with the appropriate configuration for your REST API endpoint
44+
Project information
45+
| Name: LivenessHostApp
46+
| Environment: dev
47+
| Default editor: Visual Studio Code
48+
| App type: ios
49+
50+
? Initialize the project with the above configuration? No
51+
? Enter a name for the environment: `dev`
52+
? Choose your default editor: `Xcode (macOS only)`
53+
? Choose the type of app that you're building: `ios`
54+
? Select the authentication method you want to use:
55+
`AWS profile`
56+
? Please choose the profile you want to use
57+
`default`
2558
```
26-
"awsAPIPlugin": {
27-
"liveness": {
28-
"endpointType": "REST",
29-
"endpoint": "https://xxxxxxxxxx.execute-api.us-east-1.amazonaws.com/xxxx",
30-
"region": "us-east-1",
31-
"authorizationType": "AWS_IAM"
32-
}
33-
}
59+
Wait until provisioning is finished. Upon successfully running `amplify init`, you will see a configuration file created called `amplifyconfiguration.json`. This file will be bundled into your application so that the Amplify libraries know how to reach your provisioned backend resources at runtime. You can verify by checking that the file is included in the `Copy Bundle Resources` Build Phases for the `HostApp` target in Xcode.
60+
61+
3. Configure Auth Category
62+
63+
The Amplify Auth category provides an interface for authenticating a user and also provides the necessary authorization to other Amplify categories. It comes with default, built-in support for Amazon Cognito User Pools and Identity Pools. From your project directory, run the following command to add the Amplify Auth category:
64+
```
65+
amplify add auth
3466
```
67+
Provide the responses shown after each of the following prompts.
68+
```
69+
? Do you want to use the default authentication and security configuration?
70+
`Default configuration with Social Provider (Federation)`
71+
? How do you want users to be able to sign in?
72+
`Username`
73+
? Do you want to configure advanced settings?
74+
`No, I am done.`
75+
? What domain name prefix you want us to create for you?
76+
`(default)`
77+
? Enter your redirect signin URI:
78+
`myapp://`
79+
? Do you want to add another redirect signin URI
80+
`No`
81+
? Enter your redirect signout URI:
82+
`myapp://`
83+
? Do you want to add another redirect signout URI
84+
`No`
85+
? Select the social providers you want to configure for your user pool:
86+
`<hit enter>`
87+
```
88+
4. Once finished, run `amplify push` to publish your changes.
89+
Upon completion, `amplifyconfiguration.json` should be updated to reference these provisioned backend resources.
90+
5. Follow the steps below to create an inline policy to enable authenticated app users to access Rekognition, which powers the FaceLivenessDetector.
91+
1. Go to AWS IAM console, then Roles
92+
2. Select the newly created `authRole` for the project (`amplify-<project_name>-<env_name>-<id>-authRole`).
93+
3. Choose **Add Permissions**, then select **Create Inline Policy**, then choose **JSON** and paste the following:
94+
95+
```
96+
{
97+
"Version": "2012-10-17",
98+
"Statement": [
99+
{
100+
"Effect": "Allow",
101+
"Action": "rekognition:StartFaceLivenessSession",
102+
"Resource": "*"
103+
}
104+
]
105+
}
106+
```
107+
108+
4. Choose **Review Policy**
109+
5. Name the policy
110+
6. Choose **Create Policy**
35111
36-
## Running Sample App
37-
The sample app depends on a real device camera to capture videos. Open the sample app in Xcode and deploy the app onto a real device.
112+
6. Set up a backend to create the liveness session and retrieve the liveness session results. The liveness sample app is set up to use API Gateway endpoints for creating and retrieving the liveness session. Follow the [Amazon Rekognition Liveness guide](https://docs.aws.amazon.com/rekognition/latest/dg/face-liveness-programming-api.html) to set up your backend.
38113
114+
1. Edit the [StartSessionViewModel.swift](https://github.com/aws-amplify/amplify-ui-swift-liveness/blob/main/HostApp/HostApp/Views/StartSessionViewModel.swift) in your project as necessary to generate the session id from your backend.
115+
2. Edit the [ExampleLivenessViewModel.swift](https://github.com/aws-amplify/amplify-ui-swift-liveness/blob/main/HostApp/HostApp/Views/ExampleLivenessViewModel.swift) in your project as necessary to get the liveness result from your backend.

0 commit comments

Comments
 (0)