FBSDKAccessToken currentAccessToken nil after quitting app
The problem is because you are calling for
FBSDKAccessToken.currentAccessToken() before having called
FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)
You can check for the access token anytime after calling the above line.
The above line lets the Facebook SDK process the launchOptions and extract the necessary information which it will require to recognise and persist the user for the application.
In cases where the user is already logged in, this simply initialises the Facebook SDK which in turn logs in the user on the basis of persisted data.
I spent a nice half-day banging my head against this issue. In spite of making sure all the delegate methods were present, the
FBSDKAccessToken.current() always returned nil.
It turns out that this is because Keychain Sharing is not enabled ( Xcode 8, iOS 10). To fix, go to App -> Capabilities -> Keychain Sharing and turn ON.
Once this is done, you have to still go through the authorization process and return back to the app. Everything should be fine after.
If you already tried the upon solutions, but still have the problem, try this.
My co-programmer and I are using the
LoginManager().login method provided in Facebook Swift SDK. (Xcode8, Swift 3, iOS 10)
One possible action that caused that issue is when you login successfully and kill the app immediately, then open your app again and the
nil. After login, if you wait 20 seconds or longer (we are not sure the exact waiting time, we waited for 7-20 seconds) and kill the app, the problem seemed to be solved.
We are not sure why this is happened, but this solved our problem, and our guess is that there may be a network delay or a bug.