Use AWS SDK
For advanced use cases where Amplify does not provide the functionality you're looking for, you can retrieve the escape hatch to access the underlying SDK.
The escape hatch provides access to the underlying AWSCognitoIdentityProvider
instance. Import the necessary types:
1import AWSCognitoAuthPlugin2import AWSCognitoIdentityProvider
Then retrieve the escape hatch with this code:
1func getEscapeHatch() {2 let client: CognitoIdentityProviderClient3
4 // Get the instance of AWSCognitoAuthPlugin5 let plugin = try? Amplify.Auth.getPlugin(for: "awsCognitoAuthPlugin") as? AWSCognitoAuthPlugin6
7 // Get the instance of CognitoIdentityProviderClient8 if case .userPoolAndIdentityPool(let userPoolClient, _) = plugin?.getEscapeHatch() {9 client = userPoolClient10 } else if case .userPool(let userPoolClient) = plugin?.getEscapeHatch() {11 client = userPoolClient12 } else {13 fatalError("No user pool configuration found")14 }15 print("Fetched escape hatch - \(String(describing: client))")16}