0

我使用 Facebook SDK 3.5.1 将 facebook 集成到我的 iOS 应用程序中。

当我在我的 iPhone 5(iOS 6.1.2 没有越狱)上运行它时,没问题,一切正常。

当我在我爸爸的 iPhone 4(iOS 6.1.4 没有越狱)上运行它时,会出现一些问题。当我按下登录按钮时,应用程序会显示警报“AppName 想要访问您的基本信息和朋友列表”,当我按下确定时,什么也没有发生(在我的 iPhone 5 上,它在此警报后登录)。当我再次按下登录按钮时,会弹出相同的警报,这一切都重新开始。

在我的模拟器(iOS 6.1)中,我遇到了完全相同的问题。如果我在模拟器的设置中禁用 facebook 登录,它会显示一个带有登录字段而不是警报框的弹出窗口。

在这种情况下,我的模拟器记录以下内容: FBSDKLog: 无法使用 Facebook 应用程序或 Safari 进行授权,BLOCKED_OUT 未注册为 URL 方案

我读到这可能会发生,因为模拟器上没有安装 facebook 应用程序。但即使使用这种登录方式,它也不起作用。

我在 facebook 上使用了与此页面完全相同的代码: https ://developers.facebook.com/ios/login-ui-control/

FBLoginView *loginView = [[FBLoginView alloc] init];

    loginView.delegate = self;
    // Align the button in the center horizontally
    loginView.frame = CGRectMake((self.view.center.x - (loginView.frame.size.width / 2)), 150, loginView.frame.size.width, loginView.frame.size.height);
    [self.view addSubview:loginView];
    [loginView sizeToFit];

谁能帮我?

更新:

我实现了以下方法,在我按下登录按钮并授予我的应用访问权限后,它告诉我用户取消登录。

- (void)loginView:(FBLoginView *)loginView 
        handleError:(NSError *)error {
    NSString *alertMessage, *alertTitle;
    if (error.fberrorShouldNotifyUser) {
        // If the SDK has a message for the user, surface it. This conveniently
        // handles cases like password change or iOS6 app slider state.
        alertTitle = @"Facebook Error";
        alertMessage = error.fberrorUserMessage;
    } else if (error.fberrorCategory == FBErrorCategoryAuthenticationReopenSession) {
        // It is important to handle session closures since they can happen 
        // outside of the app. You can inspect the error for more context 
        // but this sample generically notifies the user.
        alertTitle = @"Session Error";
        alertMessage = @"Your current session is no longer valid. Please log in again.";
    } else if (error.fberrorCategory == FBErrorCategoryUserCancelled) {
        // The user has cancelled a login. You can inspect the error
        // for more context. For this sample, we will simply ignore it.
        NSLog(@"user cancelled login");
    } else {
        // For simplicity, this sample treats other errors blindly.
        alertTitle  = @"Unknown Error";
        alertMessage = @"Error. Please try again later.";
        NSLog(@"Unexpected error:%@", error);
    }

    if (alertMessage) {
        [[[UIAlertView alloc] initWithTitle:alertTitle
                                    message:alertMessage
                                   delegate:nil
                          cancelButtonTitle:@"OK"
                          otherButtonTitles:nil] show];
    }
}
4

1 回答 1

0

除了基本登录之外,您是否还要求额外的权限?

我在尝试请求publish_actions许可时遇到了类似的问题。一旦我删除了这个权限,它又开始工作了。

此外,在 iPhone 本身上,如果您在 iPhone 上安装了 Facebook 应用程序,请确保您的应用程序允许使用它进行连接。转到设置 > Facebook 并确保您的应用已启用登录。

此外,请确保应用程序未处于“沙盒”模式。如果您处于沙盒模式,请创建一个测试用户帐户来测试应用程序。

于 2013-05-27T20:38:01.970 回答