Here is my answer: for me there were several keywords like FBSessionStateCreatedTokenLoaded . It could help
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { // Whenever a person opens the app, check for a cached session if FBSession.activeSession().state == FBSessionState.CreatedTokenLoaded { // If there one, just open the session silently, without showing the user the login UI FBSession.openActiveSessionWithReadPermissions(["public_profile"], allowLoginUI: false, completionHandler: { (session, state, error) -> Void in self.sessionStateChanged(session, state: state, error: error) }) } return true } func sessionStateChanged(session : FBSession, state : FBSessionState, error : NSError?) { // If the session was opened successfully if state == FBSessionState.Open { println("Session Opened") } // If the session closed if state == FBSessionState.Closed { println("Closed") } }
On button click Facebook login button
@IBAction func FacebookLoginPressed(Sender: AnyObject) { if (FBSession.activeSession().state == FBSessionState.Open || FBSession.activeSession().state == FBSessionState.OpenTokenExtended) {
source share