gpt4 book ai didi

ios - Facebook SDK 原生登录报错

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:17:07 25 4
gpt4 key购买 nike

注意:我遵循来自 Native Facebook Login stopped working after SDK update to 3.14 的 native 登录建议.

错误如下:

2014-10-13 20:03:27.378 Registration[1916:407643] Error Domain=com.facebook.sdk Code=9 "Access has not been granted to the Facebook account. Verify device settings." UserInfo=0x1753c630 {NSLocalizedDescription=Access has not been granted to the Facebook account. Verify device settings., NSLocalizedFailureReason=Access has not been granted to the Facebook account. Verify device settings.}

这是下面的代码:

//RegistrationManager.m

- (void)setupFacebook
{
FBSessionStateHandler completionHandler = ^(FBSession *session, FBSessionState status, NSError *error) {
[self sessionStateChanged:session state:status error:error];
};

if ([FBSession activeSession].state == FBSessionStateCreatedTokenLoaded)
{
// we have a cached token, so open the session
[[FBSession activeSession] openWithBehavior:FBSessionLoginBehaviorUseSystemAccountIfPresent
completionHandler:completionHandler];
}
else
{
[self clearAllUserInformation];

// create a new facebook session
FBSession *fbSession = [[FBSession alloc] initWithPermissions:@[@"public_profile"]];
[FBSession setActiveSession:fbSession];
[fbSession openWithBehavior:FBSessionLoginBehaviorUseSystemAccountIfPresent completionHandler:completionHandler];
}
}

- (void)clearAllUserInformation
{
[FBSession.activeSession closeAndClearTokenInformation];
[FBSession renewSystemCredentials:^(ACAccountCredentialRenewResult result, NSError *error) {
NSLog(@"%@", error);
}];
[FBSession setActiveSession:nil];
}

//RegistrationViewController.m

- (IBAction)loginButtonPressed:(id)sender
{
// If the session state is any of the two "open" states when the button is clicked
if (FBSession.activeSession.state == FBSessionStateOpen
|| FBSession.activeSession.state == FBSessionStateOpenTokenExtended)
{
// Close the session and remove the access token from the cache
// The session state handler (in the app delegate) will be called automatically
[FBSession.activeSession closeAndClearTokenInformation];

// If the session state is not any of the two "open" states when the button is clicked
} else
{
FBSessionStateHandler completionHandler = ^(FBSession *session, FBSessionState status, NSError *error) {
[registrationManager sessionStateChanged:session state:status error:error];
};

// create a new facebook session
FBSession *fbSession = [[FBSession alloc] initWithPermissions:@[@"public_profile"]];
[FBSession setActiveSession:fbSession];
[fbSession openWithBehavior:FBSessionLoginBehaviorUseSystemAccountIfPresent completionHandler:completionHandler];
}
}

当我点击按钮时,它只是说

2014-10-13 20:03:29.560 Registration[1916:407643] Session closed 2014-10-13 20:03:29.561 Registration[1916:407643] User logs out. 2014-10-13 20:03:29.573 Registration[1916:407643] User logs out.

最佳答案

这意味着用户曾经在请求权限的弹出窗口中选择了“不允许”。如果他在“设置”中链接了他的 Facebook 帐户,从现在开始,每次他尝试登录时都会显示此错误。它不会回退到 Safari 或任何东西,只是显示这个错误。用户需要进入“设置”->“Facebook”并将您应用的 slider 设置为“打开”。

关于ios - Facebook SDK 原生登录报错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26350917/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com