I've implemented Facebook Connect in my app just like the sample app that Facebook provides and it works well. After a user chooses to share data via Facebook they are taken to a new view and presented with the FB login dialog. When the user is done they exit the FB sharing view and return to my app's previous view. The user stays logged in as long as they don't logout - even if they exit the FB sharing view. This is good and as expected.
I'm using the same viewDidLoad method as the sample SessionViewController.m, and this is where _session is initialized:
- (void)viewDidLoad {
[_session resume];
_loginButton.style = FBLoginButtonStyleWide;
}
However I noticed that if the user presses the Logout button after exiting and re-loading the FB sharing view it will throw SIGABRT or EXC_BAD_ACCESS and crash the app. The EXC_BAD_ACCESS error occurs at the [dialog show] line of the Login button's touchUpInside method:
- (void)touchUpInside {
if (_session.isConnected) {
[_session logout];
} else {
FBLoginDialog* dialog = [[[FBLoginDialog alloc] initWithSession:_session] autorelease];
[dialog show];
}
Even though the user is connected the touchUpInside method is seeing a disconnected session... Sometimes instead of crashing after pressing the Logout button the logout will be successful but the view's status text remains "Logged in as ..." and the set status/upload image buttons are not hidden. Trying to log in again throws a SIGABRT, which looks due to a nil _session.sessionKey in FBRequest.m:344:
[_params setObject:_session.sessionKey forKey:@"session_key"];
Is there something I should be retaining or doing differently across view changes?
EDIT: I found another user having this same issue on the Facebook Developer Forums: http://forum.developers.facebook.com/viewtopic.php?pid=193727#p193727
There is no solution posted but if I find one I'll update this question.