M S*_*M S 22 facebook ios facebook-login ios6
嗨,我正在使用ios6 for facebook登录,我收到此错误作为本机弹出窗口
该操作无法完成.(com.facebook.sdk错误2.)
这是我使用过的场景.(我在simularor上运行它)
我已通过设置登录到Facebook应用程序,我尝试登录到我的应用程序,其工作正常.
然后我从设置中退出Facebook并再次使用不同的用户登录.然后我尝试登录该应用程序.我收到了这个错误.
我尝试使用该命令退出应用程序
[FBSession.activeSession closeAndClearTokenInformation];
但没用.
Facebook应用程序中的包标识符与我的ios应用程序中的相同.
这是我用来登录的代码
NSArray *permissions = [[NSArray alloc] initWithObjects:@"email", nil];
[FBSession openActiveSessionWithReadPermissions:permissions
allowLoginUI:YES
completionHandler:
^(FBSession *session,
FBSessionState state, NSError *error) {
[self sessionStateChanged:session state:state error:error];
}];
Run Code Online (Sandbox Code Playgroud)
任何帮助表示赞赏.
这是我得到的错误
Domain = com.facebook.sdk Code = 2"操作无法完成.(com.facebook.sdk error 2.)"UserInfo = 0x9535330 {com.facebook.sdk:ErrorLoginFailedReason = com.facebook.sdk:SystemLoginDisallowedWithoutError, com.facebook.sdk:ErrorSessionKey =,expirationDate:(null),refreshDate:(null),attemptsRefreshDate:0001-12-30 00:00:00 +0000,permissions:(null)>}
注意 我在不同的视频上得到了相同的错误.那时我的代码中有一个错误
而不是给予许可
NSArray *permissions = [[NSArray alloc] initWithObjects:@"email",@"birthday", nil];
我做错了
NSArray *permissions = [[NSArray alloc] initWithObjects:@"email,birthday", nil];
解决方案 即使在纠正代码后,我也遇到了同样的错误.我必须从ios设置屏幕注销并登录facebook.一旦我这样做,正确的代码从未引起任何问题.请注意,问题仅发生在先前执行错误代码的设备上.请注意确定导致问题的原因,希望此信息有助于某人
Boc*_*ica 23
这对我有用:
这可能发生在任何设备上,因此在您的应用程序中,您必须确保正确处理此错误.我估计你向用户提供反馈为何登录Facebook失败并要求用户在他们的设备上检查他们的Facebook设置.
- (void)facebookSessionStateChanged:(FBSession *)session state:(FBSessionState)state error:(NSError *)error
{
switch (state) {
case FBSessionStateOpen:
// handle successful login here
case FBSessionStateClosed:
case FBSessionStateClosedLoginFailed:
[FBSession.activeSession closeAndClearTokenInformation];
if (error) {
// handle error here, for example by showing an alert to the user
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Could not login with Facebook"
message:@"Facebook login failed. Please check your Facebook settings on your phone."
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
}
break;
default:
break;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
95166 次 |
| 最近记录: |