openSessionWithAllowLoginUI几乎总是返回NO [英] openSessionWithAllowLoginUI almost always returns NO

查看:95
本文介绍了openSessionWithAllowLoginUI几乎总是返回NO的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近我完成了将最新的FB iOS SDK(3.0)整合到我的应用程序(iOS 5)中。我已经浏览了这些教程,根据FB提供的文档,一切似乎都已经到位了。我遇到的问题是,每当我检查是否需要通过以下方式进行身份验证:



if(![self openSessionWithAllowLoginUI:NO])
{
[self openSessionWithAllowLoginUI:YES];
}



...经常(并且几乎总是在[FBSession.activeSession close]之后)openSessionWithAllowLoginUI返回NO,我必须转换到身份验证对话框获得有效的会话。根据我的理解,[FBSession.activeSession close]不应该破坏SDK重新使用旧令牌的能力,并允许我重新创建会话,而不必显示登录对话框。



请注意,在我的应用程序中,我的应用程序生命周期内不需要Facebook身份验证。因此,我倾向于根据需要建立会话,并在完成时将其与[FBSession.activeSession close]完全关联,而不是仅在ApplicationWillTerminate中有[FBSession.activeSession close]。



有没有人对我可能做错了什么或尝试的东西有任何建议?



谢谢。

解决方案

我无法让openSessionWithAllowLoginUI正常工作。相反,使用这个:

  [FBSession openActiveSessionWithPermissions:[NSArray arrayWithObject:@user_relationships] allowLoginUI:YES completionHandler:^(FBSession * session,FBSessionState status,NSError * error){
switch(status){
case FBSessionStateOpen:
[self start];
break;
case FBSessionStateClosed:
break;
case FBSessionStateCreated:
break;
case FBSessionStateCreatedOpening:
break;
case FBSessionStateClosedLoginFailed:
break;
case FBSessionStateOpenTokenExtended:
break;
case FBSessionStateCreatedTokenLoaded:
break;
}

}];

添加一个[self start]方法并修改权限数组以满足您的需要。这样做一贯。


I've recently finished integrating the latest FB iOS SDK (3.0) into my app (iOS 5). I've stepped through the tutorials, and everything appears to be in place according to the FB provided docs. The issue I'm having is that whenever I check to see if I need to authenticate via:

if(![self openSessionWithAllowLoginUI:NO]) { [self openSessionWithAllowLoginUI:YES]; }

... often (and almost always after [FBSession.activeSession close]) openSessionWithAllowLoginUI returns NO, and I have to transition to the authentication dialog to get a valid session. According to my understanding, [FBSession.activeSession close] should not disrupt the ability of the SDK to re-use old tokens and allow me to recreate a session without having to display the login dialog.

Note that in my app, I don't require Facebook authentication for the duration of the app lifetime. Therefore, I tend to establish sessions on demand, and tear them down with [FBSession.activeSession close] exactly when I'm done, as opposed to only having [FBSession.activeSession close] in applicationWillTerminate.

Does anyone have any suggestions on what I might be doing wrong or things to try?

Thanks.

解决方案

I could never get openSessionWithAllowLoginUI to work properly. Instead, use this:

[FBSession openActiveSessionWithPermissions:[NSArray arrayWithObject:@"user_relationships"] allowLoginUI:YES completionHandler:^(FBSession *session, FBSessionState status, NSError *error) {
    switch (status) {
        case FBSessionStateOpen:
            [self start];
            break;
        case FBSessionStateClosed:
            break;
        case FBSessionStateCreated:
            break;
        case FBSessionStateCreatedOpening:
            break;
        case FBSessionStateClosedLoginFailed:
            break;
        case FBSessionStateOpenTokenExtended:
            break;
        case FBSessionStateCreatedTokenLoaded:
            break;
    }

}];

Add a [self start] method and modify the permissions array to suit your needs. This works consistently.

这篇关于openSessionWithAllowLoginUI几乎总是返回NO的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆