title: Facebook SDK native login error
body: <p>Note: I am following the native login advice from <a href="https://stackoverflow.com/questions/23476499/native-facebook-login-stopped-working-after-sdk-update-to-3-14">Native Facebook Login stopped working after SDK update to 3.14</a>.</p>
  
  <p>The error is as follows:</p>
  
  <blockquote>
    <p>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.}</p>
  </blockquote>
  
  <p>This is the code below:</p>
  
  <p><strong><code>// RegistrationManager.m</code></strong></p>
  
  <pre><code>- (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];
  }
  </code></pre>
  
  <p><strong><code>// RegistrationViewController.m</code></strong></p>
  
  <pre><code>- (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];
      }
  }
  </code></pre>
  
  <p>When I click on the button, it simply says</p>
  
  <blockquote>
    <p>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.</p>
  </blockquote>