Use AWS SDK
If you need functionality in the AWS services used by the Amplify Predictions category that isn't available, we provide an escape hatch so you can get a reference to that service. For example, to get a reference to AWSRekognition
:
1guard let predictionsPlugin = try Amplify.Predictions.getPlugin(for: "awsPredictionsPlugin") as? AWSPredictionsPlugin else {2 print("Unable to cast to AWSPredictionsPlugin")3 return4}5
6guard let rekognitionService = predictionsPlugin.getEscapeHatch(key: .rekognition) as? AWSRekognition else {7 print("Unable to get AWSRekognition")8 return9}10
11let request = AWSRekognitionCreateCollectionRequest()12if let request = request {13 rekognitionService.createCollection(request)14}
In addition to AWSRekognition
, this same pattern can be used to get access to AWSTranslate
, AWSPolly
, AWSTranscribeStreaming
, AWSComprehend
, and AWSTextract
. For example:
1guard let translateService = predictionsPlugin.getEscapeHatch(key: .translate) as? AWSTranslate else {2 print("Unable to get AWSTranslate")3 return4}5
6guard let pollyService = predictionsPlugin.getEscapeHatch(key: .polly) as? AWSPolly else {7 print("Unable to get AWSPolly")8 return9}10
11guard let transcribeService = predictionsPlugin.getEscapeHatch(key: .transcribe) as? AWSTranscribeStreaming else {12 print("Unable to get AWSTranscribeStreaming")13 return14}15
16guard let comprehendService = predictionsPlugin.getEscapeHatch(key: .comprehend) as? AWSComprehend else {17 print("Unable to get AWSComprehend")18 return19}20
21guard let textractService = predictionsPlugin.getEscapeHatch(key: .textract) as? AWSTextract else {22 print("Unable to get AWSTextract")23 return24}
API Documentation Resources