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 CognitoIdentityProviderClient
and CognitoIdentityClient
instance. Then retrieve the escape hatch with this code:
Gradle Imports
1implementation "aws.sdk.kotlin:cognitoidentityprovider:KOTLIN_SDK_VERSION"2implementation "aws.sdk.kotlin:cognitoidentity:KOTLIN_SDK_VERSION"
1// Get the instance of AWSCognitoAuthPlugin2AWSCognitoAuthPlugin cognitoAuthPlugin = (AWSCognitoAuthPlugin) Amplify.Auth.getPlugin("awsCognitoAuthPlugin");3
4// Get the instance of CognitoIdentityProviderClient5CognitoIdentityProviderClient client = cognitoAuthPlugin.getEscapeHatch().getCognitoIdentityProviderClient();6ResendConfirmationCodeRequest request = ResendConfirmationCodeRequest.Companion.invoke(dslBuilder -> {7 dslBuilder.setClientId("xxxxxxxxxxxxxxxx");8 dslBuilder.setUsername("user1");9 return null;10});11
12assert client != null;13client.resendConfirmationCode(request, new Continuation<ResendConfirmationCodeResponse>() {14 @NonNull15 @Override16 public CoroutineContext getContext() {17 return GlobalScope.INSTANCE.getCoroutineContext();18 }19
20 @Override21 public void resumeWith(@NonNull Object resultOrException) {22 Log.i(TAG, "Result: " + resultOrException);23 }24});