已在 2013 年 9 月 18 日发布的FB SDK 3.8中修复。委托方法现在每次登录调用一次,无论重复注销和重新登录发生多少次。
我还能够在 FB SDK 3.7.1 和他们自己的示例程序“Scrumptious”中重现这一点
如前所述(至少对我而言),这只发生在:
- 登录一次
- 注销
- 重新登录(现在发生了)
有趣的是重新登录时的调用顺序:
在第一次登录时,我看到的电话是:
- (void)loginViewShowingLoggedInUser:(FBLoginView *)loginView;
- (void)loginViewFetchedUserInfo:(FBLoginView *)loginView user:(id<FBGraphUser>)user;
在第二次(及以后)登录时,我看到:
- (void)loginViewFetchedUserInfo:(FBLoginView *)loginView user:(id<FBGraphUser>)user;
- (void)loginViewShowingLoggedInUser:(FBLoginView *)loginView;
- (void)loginViewFetchedUserInfo:(FBLoginView *)loginView user:(id<FBGraphUser>)user;
这为在中间方法中设置标志提供了一个方便的小解决方法,如下所示:
- (void)loginViewShowingLoggedInUser:(FBLoginView *)loginView {
// Set flag
self.isFirstLoginDone = YES;
}
- (void)loginViewFetchedUserInfo:(FBLoginView *)loginView user:(id<FBGraphUser>)user {
// Check
if(self.isFirstLoginDone) {
// Execute code I want to run just once
NSLog(@"fetched");
}
// Don't forget to clear the flag (I guess it shouldn't matter if everything is cleaned up)
self.isFirstLoginDone = NO;
}