[英]Facebook login fails on iPhone 4 and Emulator
我使用Facebook SDK 3.5.1在我的iOS应用中集成了facebook。
当我在iPhone 5(iOS 6.1.2无越狱)上运行它时,一切正常都没问题。
当我在爸爸的iPhone 4(iOS 6.1.4无越狱)上运行它时,会出现一些问题。 当我按下登录按钮时,应用程序会显示一条警报“ AppName想要访问您的基本信息和朋友列表”,当我按下ok时,什么都没有发生(在我的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];
}
}
除了基本登录,您还要求其他权限吗?
尝试请求publish_actions
权限时遇到了类似的问题。 删除此权限后,它将再次开始工作。
另外,在iPhone本身上,如果您在iPhone上安装了Facebook App,请确保允许您的应用程序使用它进行连接。 转到“设置”>“ Facebook”,并确保您的应用已启用登录功能。
另外,请确保该应用程序不在“沙盒”模式下。 如果您处于沙盒模式,请创建一个测试用户帐户来测试该应用程序。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.