Skip to content

Instantly share code, notes, and snippets.

@kgleong
Last active December 31, 2018 05:03
Show Gist options
  • Save kgleong/34528b9523601c1a7d2cbfcc0180fb58 to your computer and use it in GitHub Desktop.
Save kgleong/34528b9523601c1a7d2cbfcc0180fb58 to your computer and use it in GitHub Desktop.
Google Sign In - View Controller - Add Sign In Button
import GoogleSignIn
class ViewController: UIViewController {
let googleSignInButton = UIButton()
override func viewDidLoad() {
super.viewDidLoad()
view.addSubview(googleSignInButton)
googleSignInButton.setTitle("Google Sign In", for: .normal)
googleSignInButton.addTarget(self, action: #selector(onGoogleSignInButtonTap), for: .touchUpInside)
// ...
}
@objc private func onGoogleSignInButtonTap() {
GIDSignIn.sharedInstance()?.signIn()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment