I'm trying to somehow save my Access Token/stay logged in upon app quit/crash. I am able to login to Facebook and retrieve data with the FBSDKGraphRequest but every time I quit the app, I am confronted with yet another login screen asking for my authentication (and saying I've already authorized this application) After doing numerous Google searches pertaining to the specific FBSDK version, I've found close to nothing that can help me with somehow keeping the current user logged into Facebook.
FBSession is deprecated (thus I cannot use it since it's not in the most current SDK anymore) and instead I have to do something with FBSDKAccessToken but I really have no clue as to what I have to do.
Here is the current code I'm using to check if currently logged in:
AppTabBarController (type UITabBarController)
override func viewDidAppear(_ animated: Bool) {
if FBSDKAccessToken.current() == nil {
//Go to Facebook Login Screen
performSegue(withIdentifier: "toFBLogin", sender: self)
}
}
AppDelegate
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
FBSDKApplicationDelegate.sharedInstance()
return true
}
func applicationDidBecomeActive(_ application: UIApplication) {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
FBSDKAppEvents.activateApp();
}
func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: AnyObject) -> Bool {
return FBSDKApplicationDelegate.sharedInstance().application(application, open: url, sourceApplication: sourceApplication, annotation: annotation)
}
...//Plus rest of protocol-required functions.
My problem is that there is no way to save the AccessToken that I know of. (Whenever the app launches, the FBSDKAccessToken.current()
is nil)