So I implemented an FB login into my app with the following in view controller.swift file
func loginButton(loginButton: FBSDKLoginButton!, didCompleteWithResult result: FBSDKLoginManagerLoginResult!, error: NSError!) {
if error == nil
{
print("Login Successful")
}
else
{
print(error.localizedDescription)
}
}
From this point though I am not sure how/where to call a function to segue after a successful login, I am new to swift so any detailed explanation would be great.
your code is fine , at the same time you need to implement the performSegueWithIdentifier
for segue
use segue identifier in Push Method and give the proper connection
if you are using Identifier
, then call this line where u need
self.performSegueWithIdentifier("identifierName", sender: self)
func loginButton(loginButton: FBSDKLoginButton!, didCompleteWithResult result: FBSDKLoginManagerLoginResult!, error: NSError!) {
if error == nil
{
print("Login Successful")
self.performSegueWithIdentifier("identifierName", sender: self)
}
else
{
print(error.localizedDescription)
}
}
Choice-2
if use `storyboard ID` with connection less
for example
func loginButton(loginButton: FBSDKLoginButton!, didCompleteWithResult result: FBSDKLoginManagerLoginResult!, error: NSError!) {
if error == nil
{
print("Login Successful")
let second = self.storyboard?.instantiateViewControllerWithIdentifier("SecondViewControllerSegue") as? SecondViewController
self.navigationController?.pushViewController(second!, animated: true)
}
else
{
print(error.localizedDescription)
}
}