Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 7b6a2af

Browse files
ivo.liondovivo.liondov
ivo.liondov
authored and
ivo.liondov
committed
Update images and instructions to cover watchos
1 parent 2cc590d commit 7b6a2af

File tree

4 files changed

+15
-11
lines changed

4 files changed

+15
-11
lines changed

‎SHAPES-EXAMPLE.md‎

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Shapes Example
22

3-
This quickstart is written specifically for native iOS and watchOS apps that are written in Swift for making the API calls that you wish to protect with Approov. This quickstart provides a step-by-step example of integrating Approov into an app using a simple `Shapes` example that shows a geometric shape based on a request to an API backend that can be protected with Approov.
3+
This quickstart is written specifically for native iOS and watchOS apps that are written in Swift for making the API calls that you wish to protect with Approov. This quickstart provides a step-by-step example of integrating Approov into an app using a simple `Shapes` example that shows a geometric shape based on a request to an API backend that can be protected with Approov. The project targets both iOS and watchOS, allowing you to execute and integrate Approov independently for each platform.
44

55
## WHAT YOU WILL NEED
66
* Access to a trial or paid Approov account
@@ -19,22 +19,24 @@ Select your code signing certificate in the `Signing & Capabilities` tab and run
1919

2020
Once the application is running you will see two buttons:
2121

22-
<divstyle="display: flex; justify-content: space-between;">
23-
<img src="readme-images/first-image.png" width="256" title="First Image Title">
22+
<p>>
23+
<img src="readme-images/app-startup.png" width="256" title="First Image Title">
2424
<img src="readme-images/watch-app-startup.png" width="256" title="Shapes App Startup">
25-
</div>
25+
</p>
2626

2727

2828
Click on the `Hello` button and you should see this:
2929

3030
<p>
3131
<img src="readme-images/hello-okay.png" width="256" title="Hello Okay">
32+
<img src="readme-images/watch-hello-okay.png" width="256" title="Hello Okay">
3233
</p>
3334

3435
This checks the connectivity by connecting to the endpoint `https://shapes.approov.io/v1/hello`. Now press the `Shape` button and you will see this (or another shape):
3536

3637
<p>
3738
<img src="readme-images/shape.png" width="256" title="Shape">
39+
<img src="readme-images/watch-shape.png" width="256" title="Shape">
3840
</p>
3941

4042
This contacts `https://shapes.approov.io/v1/shapes` to get the name of a random shape. This endpoint is protected with an API key that is built into the code, and therefore can be easily extracted from the app.
@@ -47,13 +49,13 @@ The Approov integration is available via the [`Swift Package Manager`](https://d
4749

4850
![Add Packag Dependency](readme-images/AddPackage.png)
4951

50-
Enter the repository`https://github.com/approov/approov-service-urlsession.git` into the search box. You will then have to select the relevant version you wish to use. To do so, select the `Exact Version`, after which the latest `tag` from the selected repository should be selected. If you would like to use an earlier version, just replace the latest one.
52+
Enter the repository`https://github.com/approov/approov-service-urlsession.git` into the search box. You will then have to select the relevant version you wish to use. To do so, select the `Exact Version`, after which the latest `tag` from the selected repository should be selected. If you would like to use an earlier version, just replace the latest one, but bear in mind that the combined watchOS and iOS support began with version `3.2.7`.
5153

52-
Once you click `Add Package` the last step will confirm the package product and target selection:
54+
Once you click `Add Package` the last step will confirm the package product and target selection. Please, make sure you select a library for each one of your targets:
5355

5456
![Target Selection](readme-images/target-selection.png)
5557

56-
The `approov-service-urlsession` is actually an open source wrapper layer that allows you to easily use Approov with `URLSession`. This has a further dependency to the closed source [Approov SDK](https://github.com/approov/approov-ios-sdk).
58+
The `approov-service-urlsession` is actually an open source wrapper layer that allows you to easily use Approov with `URLSession`. This has a further dependency to the closed source [Approov SDK](https://github.com/approov/approov-ios-sdk).
5759

5860
## ENSURE THE SHAPES API IS ADDED
5961

@@ -67,20 +69,20 @@ Tokens for this domain will be automatically signed with the specific secret for
6769

6870
## MODIFY THE APP TO USE APPROOV
6971

70-
Before using Approov you need to import the `ApproovURLSession` Service. In the `ViewController.swift` source file import the service module:
72+
Before using Approov you need to import the `ApproovURLSession` Service. In the `ViewController.swift` and/or `ContentView.swift`source file import the service module:
7173

7274
```swift
7375
import ApproovURLSession
7476
```
7577

76-
Find the following line in `ViewController.swift` source file and uncomment it (commenting the previous definition):
78+
Find the following line in `ViewController.swift` and `ContentView.swift`source file and uncomment it (commenting the previous definition):
7779

7880
```swift
7981
//*** UNCOMMENT THE LINE BELOW FOR APPROOV
8082
var defaultSession = ApproovURLSession(configuration: .default)
8183
```
8284

83-
Now locate and uncomment the line inside the `viewDidLoad` function that initializes the `ApproovService` and remember to add the `config` parameter. The `approov-service-urlsession` needs a configuration string to identify the account associated with the app. You will have received this in your Approov onboarding email (it will be something like `#123456#K/XPlLtfcwnWkzv99Wj5VmAxo4CrU267J1KlQyoz8Qo=`):
85+
Now locate and uncomment the line inside the `viewDidLoad` or `init`function that initializes the `ApproovService` and remember to add the `config` parameter. The `approov-service-urlsession` needs a configuration string to identify the account associated with the app. You will have received this in your Approov onboarding email (it will be something like `#123456#K/XPlLtfcwnWkzv99Wj5VmAxo4CrU267J1KlQyoz8Qo=`):
8486

8587
```swift
8688
try! ApproovService.initialize(config: "<enter-your-config-string-here>")
@@ -125,6 +127,7 @@ Run the app (without any debugger attached) and press the `Shape` button. You sh
125127

126128
<p>
127129
<img src="readme-images/shape-approoved.png" width="256" title="Shape Approoved">
130+
<img src="readme-images/watch-shape-approoved.png" width="256" title="Shape Approoved">
128131
</p>
129132

130133
This means that the app is getting a validly signed Approov token to present to the shapes endpoint.
@@ -144,7 +147,7 @@ If you still don't get a valid shape then there are some things you can try. Rem
144147

145148
This section provides an illustration of an alternative option for Approov protection if you are not able to modify the backend to add an Approov Token check. We are still going to be using `https://shapes.approov.io/v1/shapes/` that simply checks for an API key, so please change back the code so it points to `https://shapes.approov.io/v1/shapes/`.
146149

147-
The `apiSecretKey` variable also needs to be changed as follows, removing the actual API key out of the code. Find this line and uncomment it (commenting the previosu definition):
150+
The `apiSecretKey` variable also needs to be changed as follows, removing the actual API key out of the code. Find this line and uncomment it (commenting the previous definition):
148151

149152
```swift
150153
//*** UNCOMMENT THE LINE BELOW FOR APPROOV USING SECRETS PROTECTION
@@ -172,6 +175,7 @@ Run the app again and press the `Get Shape` button. You should now see this (or
172175

173176
<p>
174177
<img src="readme-images/shape.png" width="256" title="Shape">
178+
<img src="readme-images/watch-shape.png" width="256" title="Shape">
175179
</p>
176180

177181
This means that the app is able to access the API key, even though it is no longer embedded in the app code, and provide it to the shapes request.

‎readme-images/shape.png‎

118 KB
Loading[フレーム]

‎readme-images/target-selection.png‎

39.1 KB
Loading[フレーム]
74.6 KB
Loading[フレーム]

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /