I implemented the whole iOS Facebook login process in one of my iOS Game. In the app, you can either log-in with an email account or through Facebook. I occasionally present a view inviting the user to sync his account with Facebook if he logged-in with an email.
Here is the code I'm using to determine wheither or not I should display this view to the user :
if (FBSession.activeSession.isOpen) {
// Present the view
} else {
// Go somewhere else
}
At first it seemed to work great but it turns out that FBSession.activeSession.isOpen returns NO at some point even though the user is logged in with FB.
My first guess would be that the accessToken expires. I am not sure if it's a good clue because I am doing the following in my application:didFinishLaunchingWithOptions: method (like Facebook recommends to):
if (FBSession.activeSession.state == FBSessionStateCreatedTokenLoaded) {
// Yes, so just open the session (this won't display any UX).
[self openSessionWithCompletionBlock:^{}];
}
So now I have no idea how to reproduce or to fix this problem, any idea? Is it possible that the token expires after the app started? Like if the user keeps the app in background for a quiet long time?