Last active
August 28, 2017 00:44
-
-
Save amarjitdhillon/f637806bda655c46930a026f16f43555 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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