title: FBSDKAccessToken currentAccessToken nil after quitting app
body: <p>I am developing an ios app using the Facebook SDK to login.
  I have set a <code>LogInViewController</code> as the initial View Controller in the Storyboard, from where the user logins using the FB account.</p>
  
  <p>I have another ViewController which is loaded correctly once the user logs in.</p>
  
  <p>In the AppDelegate file I am checking for <code>currentAccessToken</code> and if it is not nil, I am loading directly the second ViewController, because the user is already logged in.</p>
  
  <p>However, the <code>currentAccessToken</code> is always nil if I quit the app and relaunch it. It only works if I press the home button and re-open the app while it's still running in the background.</p>
  
  <p>Here are the details in the code:</p>
  
  <p><strong>AppDelegate.swift</strong></p>
  
  <pre><code>func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -&gt; Bool {
      self.customNavigationBar()
      if (!isIcloudAvailable()) {
          self.displayAlertWithTitle("iCloud", message: "iCloud is not available." +
             " Please sign into your iCloud account and restart this app")
          return true
      }
  
      if (FBSDKAccessToken.currentAccessToken() != nil) {
          self.instantiateViewController("MapViewController", storyboardIdentifier: "Main")
      }
  
      return FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)
  }
  
  func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject) -&gt; Bool {
      return FBSDKApplicationDelegate.sharedInstance().application(
              application,
              openURL: url,
              sourceApplication: sourceApplication,
              annotation: annotation)
  }
  
  func applicationWillResignActive(application: UIApplication) {
          FBSDKAppEvents.activateApp()
  }
  
  func applicationDidBecomeActive(application: UIApplication) {
          FBSDKAppEvents.activateApp()
  }
  </code></pre>
  
  <p><strong>LogInViewController.swift</strong></p>
  
  <pre><code>override func viewDidLoad() {
      super.viewDidLoad()    
      // Listen to the Facebook notification and when received, execute func handleFBSessionStateChangeWithNotification
  NSNotificationCenter.defaultCenter().addObserver(self, selector:"handleFBSessionStateChangeWithNotification:", name: "SessionStateChangeNotification", object: nil)
  }
  
  func handleFBSessionStateChangeWithNotification(notification: NSNotification) {
      // Switch to MapViewController when logged in
      if ((FBSDKAccessToken.currentAccessToken()) != nil) {
          let storyboard = UIStoryboard(name: "Main", bundle: nil)
          let mapViewController = storyboard.instantiateViewControllerWithIdentifier("MapViewController") as! MapViewController
          self.presentViewController(mapViewController, animated: false, completion: nil)
      }
  }
  </code></pre>
  
  <p>I don't know if it is related, but I am also getting a warning for the <code>MapViewController</code> because there is no segue put towards it from the Storyboard:</p>
  
  <blockquote>
    <p>Warning: Attempt to present MapViewController whose view is not in the
    window hierarchy!</p>
  </blockquote>