Skip to content

Instantly share code, notes, and snippets.

@davidtucker
Created May 11, 2017 01:22
Show Gist options
  • Save davidtucker/2c79cb8c08e69a36f8091dfdbeb4f3f4 to your computer and use it in GitHub Desktop.
Save davidtucker/2c79cb8c08e69a36f8091dfdbeb4f3f4 to your computer and use it in GitHub Desktop.
Cognito Delegate Implementation in AppDelegate.swift
extension AppDelegate: AWSCognitoIdentityInteractiveAuthenticationDelegate {
func startPasswordAuthentication() -> AWSCognitoIdentityPasswordAuthentication {
if(self.navigationController == nil) {
self.navigationController = self.window?.rootViewController as? UINavigationController
}
if(self.loginViewController == nil) {
self.loginViewController = self.storyboard?.instantiateViewController(withIdentifier: "LoginViewController") as? LoginViewController
}
DispatchQueue.main.async {
if(self.loginViewController!.isViewLoaded || self.loginViewController!.view.window == nil) {
self.navigationController?.present(self.loginViewController!, animated: true, completion: nil)
}
}
return self.loginViewController!
}
func startNewPasswordRequired() -> AWSCognitoIdentityNewPasswordRequired {
if (self.resetPasswordViewController == nil) {
self.resetPasswordViewController = self.storyboard?.instantiateViewController(withIdentifier: "ResetPasswordController") as? ResetPasswordViewController
}
DispatchQueue.main.async {
if(self.resetPasswordViewController!.isViewLoaded || self.resetPasswordViewController!.view.window == nil) {
self.navigationController?.present(self.resetPasswordViewController!, animated: true, completion: nil)
}
}
return self.resetPasswordViewController!
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment