I getting trying to get familiar with FB's newest IOS SDK (4.0.1). I've integrated it into an IOS8 Swift project and using the FBSDKLoginButton to log users in and out. I want the application to skip showing the Login view controller if the user has already logged in.
Should I just be checking the return result of FBSDKAccessToken currentAccessToken()? Does this return 'nil' if a user is not logged in? The docs have the following to say about this method:
You can load this with the SDK from a keychain cache or from an app bookmark when your app cold launches. You should check its availability in your view controller's viewDidLoad.
Something like:
// LoginViewController.swift
override func viewDidLoad() {
super.viewDidLoad()
if(FBSDKAccessToken.currentAccessToken()){
//They are logged in so show another view
}else{
//They need to log in
}
}
So this sounds like it might be what I'm looking for but I can't really tell from this description. How are the good people of SO handling this common use case? :)
-Nick