title: Logout from facebook in iOS app
body: <p>I am creating a simple iOS App that Login to facebook, Fetch self and friends details, Logout from facebook.</p>
  
  <p>Now Login from Facebook and Fetching self &amp; friends details is working ok, but I am not able to logout fully from facebook. Whenever I logout and then Login back - I see the Authorization screen instead of Authentication Login screen of Facebook (of Web).</p>
  
  <p>Below is my code - can you please see if there is something wrong in the steps I have performed from Login, to Fetching self &amp; friends details and Logging out from facebook</p>
  
  <p>1) Login to Facebook using below method</p>
  
  <pre><code>- (void)openSession
  {
      if(FBSession.activeSession.isOpen)
      {
          [FBSession openActiveSessionWithReadPermissions:nil
                                             allowLoginUI:NO
                                        completionHandler:
           ^(FBSession *session,
             FBSessionState state, NSError *error)
           {
               [self sessionStateChanged:session state:state error:error];
           }];
      }
      else
      {
          [FBSession openActiveSessionWithReadPermissions:nil
                                             allowLoginUI:YES         
                                        completionHandler:
           ^(FBSession *session,
             FBSessionState state, NSError *error)
           {
               [self sessionStateChanged:session state:state error:error];
           }];
      }
  }
  
  - (void)sessionStateChanged:(FBSession *)session
                        state:(FBSessionState) state
                        error:(NSError *)error
  {
      switch (state) {
          case FBSessionStateOpen:
          {
              // Connection is Open
              lblStatus.text = @"FBSessionStateOpen";
          }
              break;
          case FBSessionStateClosed:
          case FBSessionStateClosedLoginFailed:
          {
              [FBSession.activeSession closeAndClearTokenInformation];
  
              // Connection is Closed / Login Failed
              lblStatus.text = @"FBSessionStateClosed";
          }
              break;
          default:
              break;
      }
  }
  </code></pre>
  
  <p>2) Fetching self details and Friends details using below method</p>
  
  <pre><code>if (FBSession.activeSession.isOpen)
  {
  [[FBRequest requestForMe] startWithCompletionHandler:
   ^(FBRequestConnection *connection,
     NSDictionary&lt;FBGraphUser&gt; *user,
     NSError *error) {
       if (!error) {
           self.lblSelfDetails.text = user.name;
           self.profilePicture.profileID = user.id;
       }
   }];
  }
  
  FBRequest *friendRequest = [FBRequest requestForGraphPath:@"me/friends?fields=name,birthday"];
  
  [friendRequest startWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error)
  {
      NSArray *data = [result objectForKey:@"data"];
  
      for (FBGraphObject&lt;FBGraphUser&gt; *friend in data)
      {
          NSLog(@"%@:%@", [friend name],[friend birthday]);
      }
  }];
  </code></pre>
  
  <p>3) Logout using below method</p>
  
  <pre><code>- (IBAction)logout:(id)sender
  {
      [FBSession.activeSession closeAndClearTokenInformation];
  }
  </code></pre>