I have followed the sample here
https://github.com/awslabs/aws-sdk-ios-samples/tree/master/CognitoYourUserPools-Sample
To integrate interactive cognito login
Sorted this now. Posting it here in case it helps anyone else.
First, you need to create a view controller that will allow the user to specify the new password. The ViewController should have a AWSTaskCompletionSource<AWSCognitoIdentityNewPasswordRequiredDetails>
as a property:
var newPasswordCompletion: AWSTaskCompletionSource<AWSCognitoIdentityNewPasswordRequiredDetails>?
Following the pattern in the sample referred to in the question, I then implemented AWSCognitoIdentityNewPasswordRequired
as an extension to the view controller as follows:
extension NewPasswordRequiredViewController: AWSCognitoIdentityNewPasswordRequired {
func getNewPasswordDetails(_ newPasswordRequiredInput: AWSCognitoIdentityNewPasswordRequiredInput, newPasswordRequiredCompletionSource:
AWSTaskCompletionSource<AWSCognitoIdentityNewPasswordRequiredDetails>) {
self.newPasswordCompletion = newPasswordRequiredCompletionSource
}
func didCompleteNewPasswordStepWithError(_ error: Error?) {
if let error = error as? NSError {
// Handle error
} else {
// Handle success, in my case simply dismiss the view controller
self.dismiss(animated: true, completion: nil)
}
}
}
Again following the design of the sample detailed in the question, add a function to the AWSCognitoIdentityInteractiveAuthenticationDelegate
extension to AppDelegate:
extension AppDelegate: AWSCognitoIdentityInteractiveAuthenticationDelegate {
func startPasswordAuthentication() -> AWSCognitoIdentityPasswordAuthentication {
//Existing implementation
}
func startNewPasswordRequired() -> AWSCognitoIdentityNewPasswordRequired {
// Your code to handle how the NewPasswordRequiredViewController is created / presented, the view controller should be returned
return self.newPasswordRequiredViewController!
}
}
The perfect example to implement the ResetPassword when u create the user in Cognito Console.
But, Integrating this ResetPassword mechanism to your existing app is your responsibility.
https://github.com/davidtucker/CognitoSampleApplication/tree/article1/CognitoApplication