基本上我浏览了这个页面并实现了我的 Facebook 登录。
https://developers.facebook.com/docs/howtos/login-with-facebook-using-ios-sdk/
接下来,当用户再次打开应用程序时,我尝试重新打开会话:
[appDelegate openSessionWithAllowLoginUI:NO];
//The method is:
- (BOOL)openSessionWithAllowLoginUI:(BOOL)allowLoginUI {
NSArray *permissions = [[NSArray alloc] initWithObjects:
@"email",
@"user_likes",
nil];
return [FBSession openActiveSessionWithReadPermissions:permissions
allowLoginUI:allowLoginUI
completionHandler:^(FBSession *session,
FBSessionState state,
NSError *error) {
[self sessionStateChanged:session
state:state
error:error];
}];
}
但是 FBSessionState 总是为 0:
/*! One of two initial states indicating that no valid cached token was found */
FBSessionStateCreated = 0,
我几乎尝试了所有方法,使用 FBSessionTokenCachingStrategy 存储和恢复令牌数据,但都没有奏效。如果我打电话
[appDelegate openSessionWithAllowLoginUI:YES];
并在会话开始时显示 LoginUI,但我不想每次都显示 LoginUI。你能帮助我吗?