ios6 facebook整合登录总是FBSessionStateClosedLoginFailed从不打开 [英] ios6 facebook integration login always FBSessionStateClosedLoginFailed never opens

查看:111
本文介绍了ios6 facebook整合登录总是FBSessionStateClosedLoginFailed从不打开的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个问题非常类似于适用于iOS的Facebook SDK,在iOS 4.0设备上,但是由于我无法在那里发表评论,我打开了一个新问题。我认为问题是不一样的:

this question is very similar to Facebook SDK for iOS , on iOS 4.0 device, but as I cannot make comments there, I open a new question. I think the questions are not the same:

尝试更新我的应用程序的Facebook整合到Facebook 3.1我没有得到Facebook会话打开sessionStateChanged回调总是最后在FBSessionStateClosedLoginFailed。在我的设置我有我的appdelegate

When trying to update the facebook integration of my app to facebook 3.1 I am not getting the facebook session to open the sessionStateChanged Callback always ends up in FBSessionStateClosedLoginFailed. in my setup I have the callback in my appdelegate

- (BOOL)application:(UIApplication *)application 
            openURL:(NSURL *)url
  sourceApplication:(NSString *)sourceApplication
         annotation:(id)annotation {
    // attempt to extract a token from the url
    //    return [self.session handleOpenURL:url]; 
    return [FBSession.activeSession handleOpenURL:url];
}

但它永远不会被调用!不应该叫吗?我按照facebook文档调用

but it is never called! shouldn't it get called? I followed the facebook documentation and call

- (BOOL)openSessionWithAllowLoginUI:(BOOL)allowLoginUI {
    NSArray *permissions = [NSArray arrayWithObjects:@"publish_actions", nil];
    return [FBSession openActiveSessionWithPublishPermissions:permissions
                                              defaultAudience:FBSessionDefaultAudienceFriends
                                              allowLoginUI:allowLoginUI
                                         completionHandler:^(FBSession *session,
                                                             FBSessionState state,
                                                             NSError *error) {
                                             [self sessionStateChanged:session
                                                                 state:state
                                                                 error:error];
                                         }];
}

我也尝试过

openActiveSessionWithReadPermissions nil 的权限,在facebook教程示例中,意图重新授权publish_actions权限。相同的结果:FBSessionStateClosedLogin再次失败。

openActiveSessionWithReadPermissions with nil for the permissions as in the facebook tutorial example with the intention to reauthorize for the publish_actions permission later. same result: FBSessionStateClosedLoginFailed again.

我甚至尝试调用

ACAccountStore *accountStore;
    ACAccountType *accountTypeFB;
    if ((accountStore = [[ACAccountStore alloc] init]) &&
        (accountTypeFB = [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook] ) ){

        NSArray *fbAccounts = [accountStore accountsWithAccountType:accountTypeFB];
        id account;
        if (fbAccounts && [fbAccounts count] > 0 &&
            (account = [fbAccounts objectAtIndex:0])){

            [accountStore renewCredentialsForAccount:account completion:^(ACAccountCredentialRenewResult renewResult, NSError *error) {
                //we don't actually need to inspect renewResult or error.
                if (error){

                }
            }];
        }
    }

它在我的ios6设备(iphone 4s)上打开。在应用程序中,我被要求获得许可,但是没有任何事情发生,因为会话始终处于状态FBSessionStateClosedLoginFailed!会话状态的回调是

before trying to open the session, but I never get it open on my ios6 device (iphone 4s). in the app I am asked for the permission, but then nothing goes on because the session is always having the state FBSessionStateClosedLoginFailed! my callback for the session state is

- (void)sessionStateChanged:(FBSession *)session
                      state:(FBSessionState) state
                      error:(NSError *)error
{
    switch (state) {
        case FBSessionStateOpen:
            if (!error) {
                // We have a valid session
                NSLog(@"User session found");
            }
            break;
        case FBSessionStateClosed:
            NSLog(@"FBSessionStateClosed");
        case FBSessionStateClosedLoginFailed:
            NSLog(@"FBSessionStateClosedLoginFailed");
            [FBSession.activeSession closeAndClearTokenInformation];
            break;
        default:
            break;
    }

    [[NSNotificationCenter defaultCenter]
     postNotificationName:FBSessionStateChangedNotification
     object:session];

    if (error) {
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"facebook Hinweis"
                                                        message:@"facebook Login nicht möglich, bitte versuchen Sie es erneut."
                                                       delegate:nil
                                              cancelButtonTitle:@"OK"
                                              otherButtonTitles:nil];
        [alert show];
        NSLog(@"Facebook session error: %@", error.localizedDescription);
    }
}

与ios 5上的facebook 3.0我没有问题所以我的Facebook应用程序设置正确。我真的非常感谢任何帮助wchich使我只是打开Facebook会议,没有想到遇到这些问题与Facebook 3.1和文档没有帮助我在这一点上,thx

with the facebook 3.0 on ios 5 I never had an issue so my facebook app is set up correctly. I would really appreciate any help wchich enables me to just open the facebook session, did not think to run into these problems with facebook 3.1 and the docs are not helping me at this point, thx

推荐答案

我有同样的问题,这是因为我忘了实现

I had the same problem, and it was because I forgot to implement

- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url
{
    return [FBSession.activeSession handleOpenURL:url];
}

在我的AppDelegate

in my AppDelegate

这篇关于ios6 facebook整合登录总是FBSessionStateClosedLoginFailed从不打开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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