Skip to content

Commit 7453581

Browse files
authored
chore: update escapehatch snippet (#1301)
1 parent 57381df commit 7453581

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

README.md

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,23 @@ Our default implementation works with Amazon Web Services (AWS), but AWS Amplify
2121
- [Predictions](https://docs.amplify.aws/lib/predictions/getting-started/q/platform/ios) - to detect text, images, and more!
2222
- [Storage](https://docs.amplify.aws/lib/storage/getting-started/q/platform/ios) - store complex objects like pictures and videos to the cloud.
2323

24-
All services and features not listed above are supported via the [iOS SDK](https://docs.amplify.aws/sdk/q/platform/ios) or if supported by a category can be accessed via the Escape Hatch like below:`
24+
All services and features not listed above are supported via the [iOS SDK](https://docs.amplify.aws/sdk/q/platform/ios) or if supported by a category can be accessed via the Escape Hatch like below:
2525

2626
```swift
27-
let rekognitionService = Amplify.Predictions.getEscapeHatch(key: .rekognition) as! AWSRekognition
28-
let request = rekognitionService.AWSRekognitionCreateCollectionRequest()
29-
rekognitionService.createCollection(request)
27+
guard let predictionsPlugin = try Amplify.Predictions.getPlugin(for: "awsPredictionsPlugin") as? AWSPredictionsPlugin else {
28+
print("Unable to cast to AWSPredictionsPlugin")
29+
return
30+
}
31+
32+
guard let rekognitionService = predictionsPlugin.getEscapeHatch(key: .rekognition) as? AWSRekognition else {
33+
print("Unable to get AWSRekognition")
34+
return
35+
}
36+
37+
let request = AWSRekognitionCreateCollectionRequest()
38+
if let request = request {
39+
rekognitionService.createCollection(request)
40+
}
3041
```
3142

3243
## Platform Support

0 commit comments

Comments
 (0)