3
votes

Note: I am following the native login advice from Native Facebook Login stopped working after SDK update to 3.14.

The error is as follows:

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.}

This is the code below:

// 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];
    }
}

When I click on the button, it simply says

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.

1

1 Answers

1
votes

It means that the user once selected "Didn't allow" in the pop-up that asks for permission. If he has his Facebook account linked in Settings, from now on, every time he'll try to login it'll show this error. It won't fallback to Safari or anything, just show this error. The user needs to got into Settings -> Facebook and set the slider for your app to ON.