Rohan_9 0 Newbie Poster

I am Working on Xcode 9.2 Swift 4.0 using FacebookSDKs-iOS-20160316 for Facebook Login Authentication Integration . My storyboard is empty .

On Running

Facebook Login button is coming on an app

When clicked Facebook login page comes, after successful login

Permission for my app is asked, When allowed following page comes

Please refer Link : https://stackoverflow.com/questions/52867810/facebook-login-button-not-changing-to-logout-button-immediate-after-login-in-swift
For images

When I click on done button of this page

I am redirected to my storyboard , and this time also same login button is there , my login button is not changed to Logout. On clicking it again following page comes:

Please refer Link : https://stackoverflow.com/questions/52867810/facebook-login-button-not-changing-to-logout-button-immediate-after-login-in-swift
For images

This is happening every Time. Please help me.

Things I have tried:

Restarted the Simulator

Restarted the Xcode

Changed Simulator

//My View Controller is having code:

class ViewController: UIViewController,FBSDKLoginButtonDelegate{

func loginButton(_ loginButton: FBSDKLoginButton!, didCompleteWithresult:     
FBSDKLoginManagerLoginResult!, error: Error!) 
 {
 print("Logged in")
 }
    func loginButtonDidLogOut(_ loginButton: FBSDKLoginButton!) 
{
    print("Logged out")
}

let loginManager: FBSDKLoginManager = FBSDKLoginManager()
override func viewDidLoad() 
  {
    super.viewDidLoad()
    let button = FBSDKLoginButton()
    button.center = self.view.center
    self.view.addSubview(button)
    button.delegate = self
  }
}