In my LoginViewController, I implemented the FBSDKLoginButtonDelegate and imported the FBSDKLoginKit & FBSDKCoreKit. My code in viewDidLoad is as appears:
//setting up facebook login button
var facebookLogin = FBSDKLoginButton()
//want this button to conform to this protocol
facebookLogin.delegate = self
facebookLogin.readPermissions = ["public_profile", "email", "user_friends"]
facebookLogin.frame = CGRectMake(20, 359, 335, 30)
self.view.addSubview(facebookLogin)
Here's the code for the button:
public func loginButton(loginButton: FBSDKLoginButton!, didCompleteWithResult
result: FBSDKLoginManagerLoginResult!, error: NSError!) {
if error != nil {
print(error.localizedDescription)
return
} else {
print("No error")
self.performSegueWithIdentifier("loginToFeed", sender: self)
}
}
After logging in, the page stays at this white screen instead of going back to the app. So I go ahead and press "Done" to manually go back to the app and my console prints that there is no error and it proceeds to going to the feed. Now the next part that's interesting is that I'm not logged in despite there being no error at login. Do you know what's going on here? Am I missing a step?