I saw this with the 3.0 SDK. The reason this happens is because facebook caches access tokens. Access tokens are cached both in the application and in the facebook application on the device (at least conceptually).
If the first time you run the application on the device, facebook will not have a valid access token cached in your application. However, it may still have a valid access token in the facebook application for your application. If he finds one on the facebook side, he does not need to prompt the user again, so a dialog box will appear, then it will disappear and send back the access token. The access token is then cached in your application.
If you restart the application (without deleting it), you will not see the login dialog, as the access token is now cached in your application. If you uninstall your application on the device and log in again, you will see the same behavior if facebook can find the cache key on the side.
I found a solution to this problem. Here is a sample code:
if (![FBSession activeSession].isOpen) { FBSession *session = [[FBSession alloc] initWithAppID:nil permissions:permissions defaultAudience:FBSessionDefaultAudienceEveryone urlSchemeSuffix:nil tokenCacheStrategy:nil]; [FBSession setActiveSession:session]; [session openWithBehavior:FBSessionLoginBehaviorUseSystemAccountIfPresent completionHandler:^(FBSession *session, FBSessionState status, NSError *error) { // NOTE openActiveSessionWithPermissions causes the facebook app to hang with a blank dialog if my app is installed, authed, and then reinstalled. openWithBehavior // does not. I think it has something to do with the FBSession activeSession. // [FBSession openActiveSessionWithPermissions:self.permissions allowLoginUI:YES completionHandler:^(FBSession *session, FBSessionState status, NSError *error) { switch (status) { case FBSessionStateOpen: [self getFacebookUser]; break; case FBSessionStateClosed: [self fbSessionClosed]; break; case FBSessionStateCreated: [self fbSessionCreated]; break; case FBSessionStateCreatedOpening: [self fbSessionOpening]; break; case FBSessionStateClosedLoginFailed: [self fbSessionClosedLoginFailed]; break; case FBSessionStateOpenTokenExtended: [self fbSessionOpenTokenExtended]; break; case FBSessionStateCreatedTokenLoaded: [self fbSessionCreatedTokenLoaded]; break; } }]; } }
openActiveSessionWithPermissions causes problems, but openWithBehavior does not. openActiveSession makes the same openWithBehavior call, but I think the setup time of the active session is different and therefore does not work. If I establish an active session before calling openWithBehavior, everything works fine. As for your application and the end user, everything is the same.
source share