Skip to content

Instantly share code, notes, and snippets.

@amarjitdhillon
Last active August 28, 2017 00:44
Show Gist options
  • Save amarjitdhillon/f637806bda655c46930a026f16f43555 to your computer and use it in GitHub Desktop.
Save amarjitdhillon/f637806bda655c46930a026f16f43555 to your computer and use it in GitHub Desktop.
import UIKit
import FBSDKLoginKit
class loginViewController: UIViewController , FBSDKLoginButtonDelegate {
override func viewDidLoad() {
super.viewDidLoad()
// initializing the button
let loginButton = FBSDKLoginButton()
//adding the button to frame
view.addSubview(loginButton)
//specifying position of login button
loginButton.frame = CGRect(x: 16, y: 50, width: view.frame.width - 32, height: 50)
// adding the delegate , also add the FBSDKLoginButtonDelegate to your class
loginButton.delegate = self
} //viewDidLoad
func loginButtonDidLogOut(_ loginButton: FBSDKLoginButton!) {
print("logout done")
}
func loginButton(_ loginButton: FBSDKLoginButton!, didCompleteWith result: FBSDKLoginManagerLoginResult!, error: Error!) {
if (error != nil){
print(error)
} //if
else{
print("login successful")
} // else
} //didCompleteWith
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment