Skip to content

Instantly share code, notes, and snippets.

@mobilequickie
Created October 11, 2018 16:17
Show Gist options
  • Save mobilequickie/8a4ced0c3bb91e735e5ae82e5421f8ee to your computer and use it in GitHub Desktop.
Save mobilequickie/8a4ced0c3bb91e735e5ae82e5421f8ee to your computer and use it in GitHub Desktop.
AWS Mobile SDK AuthUI code snippet for main ViewController. This is the same for User Pools, Facebook, and Google sign-in.
import UIKit
import AWSAuthCore
import AWSAuthUI
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
showSignIn()
}
func showSignIn() {
if !AWSSignInManager.sharedInstance().isLoggedIn {
AWSAuthUIViewController
.presentViewController(with: self.navigationController!,
configuration: nil,
completionHandler: { (provider: AWSSignInProvider, error: Error?) in
if error != nil {
print("Error occurred: \(String(describing: error))")
} else {
// Sign in successful.
print("Identity provider: \(provider.identityProviderName)")
}
})
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment