Skip to content

Commit 513e371

Browse files
authored
chore(docs): update readme with v2 snippets (#2932)
1 parent 5497c02 commit 513e371

File tree

1 file changed

+37
-24
lines changed

1 file changed

+37
-24
lines changed

README.md

Lines changed: 37 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -24,26 +24,6 @@ We deeply appreciate your feedback on this Developer Preview as we work towards
2424
- [Geo](https://docs.amplify.aws/lib/geo/getting-started/q/platform/ios) - for adding location-based capabilities to your app.
2525
- [Storage](https://docs.amplify.aws/lib/storage/getting-started/q/platform/ios) - store complex objects like pictures and videos to the cloud.
2626

27-
All services and features not listed above are supported via the [Swift SDK](https://github.com/awslabs/aws-sdk-swift) or if supported by a category can be accessed via the Escape Hatch like below:
28-
29-
```swift
30-
guard let plugin = try Amplify.Storage.getPlugin(for: "awsS3StoragePlugin") as? AWSS3StoragePlugin else {
31-
print("Unable to to cast to AWSS3StoragePlugin")
32-
return
33-
}
34-
35-
let awsS3 = plugin.getEscapeHatch()
36-
let input: HeadBucketInput = HeadBucketInput()
37-
let task = awsS3.headBucket(input: input) { result in
38-
switch result {
39-
case .success(let response):
40-
print(response)
41-
case .failure(let error):
42-
print(error)
43-
}
44-
}
45-
```
46-
4727
## Platform Support
4828

4929
Amplify supports iOS 13+ and macOS 10.15+. Support for watchOS and tvOS is coming in future releases.
@@ -90,14 +70,17 @@ Amplify requires Xcode 13.4 or higher to build.
9070

9171
```swift
9272
import Amplify
73+
import AWSCongitoAuthPlugin
9374
import AWSAPIPlugin
9475
import AWSDataStorePlugin
9576

96-
// ... later
77+
// ...
9778

9879
func initializeAmplify() {
9980
do {
81+
try Amplify.add(AWSCognitoAuthPlugin())
10082
try Amplify.add(AWSAPIPlugin())
83+
try Amplify.add(AWSDataStorePlugin())
10184
// and so on ...
10285
try Amplify.configure()
10386
} catch {
@@ -111,13 +94,43 @@ Amplify requires Xcode 13.4 or higher to build.
11194
```swift
11295
import Amplify
11396

114-
// ... later
97+
// ...
11598

116-
func doUpload() {
117-
Amplify.Storage.uploadFile(...)
99+
func signIn() async throws {
100+
let signInResult = try await Amplify.Auth.signIn(...)
101+
// ...
118102
}
119103
```
120104

105+
## Escape Hatch
106+
107+
All services and features not listed in the [**Features/API sectios**](#featuresapis) are supported via the [Swift SDK](https://github.com/awslabs/aws-sdk-swift) or if supported by a category can be accessed via the Escape Hatch like below:
108+
109+
```swift
110+
import Amplify
111+
import AWSS3StoragePlugin
112+
import AWSS3
113+
114+
// ...
115+
116+
guard let plugin = try Amplify.Storage.getPlugin(for: "awsS3StoragePlugin") as? AWSS3StoragePlugin else {
117+
print("Unable to to cast to AWSS3StoragePlugin")
118+
return
119+
}
120+
121+
let awsS3 = plugin.getEscapeHatch()
122+
123+
let accelerateConfigInput = PutBucketAccelerateConfigurationInput()
124+
do {
125+
let accelerateConfigOutput = try await awsS3.putBucketAccelerateConfiguration(
126+
input: accelerateConfigInput
127+
)
128+
print("putBucketAccelerateConfiguration output: \(accelerateConfigOutput)")
129+
} catch {
130+
print("putBucketAccelerateConfiguration error: \(error)")
131+
}
132+
```
133+
121134
## Reporting Bugs/Feature Requests
122135

123136
[![Open Bugs](https://img.shields.io/github/issues/aws-amplify/amplify-swift/bug?color=d73a4a&label=bugs)](https://github.com/aws-amplify/amplify-swift/issues?q=is%3Aissue+is%3Aopen+label%3Abug)

0 commit comments

Comments
 (0)