Jih*_*ang 7 cocoa facebook ios facebook-ios-sdk
我在我的iOS应用程序上使用Facebook的iOS SDK 3.7来处理登录.当我请求发布权限时,看起来过期日期是从登录之日起大约2个月.
我知道我可以使用[FBSession activeSession].accessTokenData.expirationDate但是会发生什么来检查到期日期,以及如何在令牌过期时处理令牌?
我又跑[FBSession openActiveSessionWithReadPermissions:allowLoginUI:completionHandler:];了吗?
我这样做了,FB 会自动重新创建会话。如果 FB 更改了使用条款或其他内容,则会向用户显示登录对话框。
// call this before any calls to FB api
- (void)openSession
{
 if(FBSession.activeSession.state != FBSessionStateOpen)
{
    [FBSession openActiveSessionWithPublishPermissions:@[FB_PUBLISH_ACTIONS_PREMISSION]
                                       defaultAudience:FBSessionDefaultAudienceFriends
                                          allowLoginUI:NO
                                     completionHandler:^(FBSession *session, FBSessionState status, NSError *error) {
                    if(!error && session.isOpen)
                    {
                    }
                    else
                    {
                        _lastError = error;
                        // handle the error
                    }
                       // here, you can handle the session state changes in switch case or
                      //something else
                    [self session:session
                  hasChangedState:status
                        withError:error];
                }];
        }
}
| 归档时间: | 
 | 
| 查看次数: | 1768 次 | 
| 最近记录: |