My problem is very similar to this question, however I am posting a new one, as the answer to the aforementioned does not seem to solve my problem.
I have a multiview application - the first view is where the user logs in to Facebook, and the second where he picks an image an开发者_开发知识库d uploads it there. The first time the app runs, everything works fine, however if I return to the login view and press logout, then any calls to sessionDidNotLogin
, sessionDidLogout
or session didLogin
don't seem to work.
I found out that the first time, if I NSLog(@"%@",session.delegates);
I have 2; my LoginViewController and the FBLoginButton. However, apart from that first time, the same log prints only the LoginViewController and not the FBLoginButton. I guess this is connected somehow, but I don't know how to solve it.
Do I have to manually add the FBLoginButton to the session delegates, or I'm doing something else wrong here?
Thank you for any help/suggestion.
I figured out the problem, thanks to a post from the Facebook developers forum. Everytime a view was loaded, I was creating a new session instance (even though I thought that it would be a singleton and the library should have taken care of it).
So, in order to make this work:
fbSession = [FBSession session];
if (!fbSession) {
fbSession = [[FBSession sessionForApplication:kApiKey secret:kApiSecret delegate:self] retain];
} else {
[[fbSession delegates] addObject:self];
}
精彩评论