title: While logging into facebook getting The Operation couldn't be completed.(com.facebook.sdk error 2.0) error. iOS 6,iPhone3gs
body: <p>I have integrated facebook sdk 3.2.1 in my app, When i am trying to login i am getting this error </p>
  
  <pre><code>The Operation couldn't be completed.(com.facebook.sdk error 2.0) error. iOS 6
  </code></pre>
  
  <p>This is mainly occurring when User's phone has preinstalled Facebook App, and when he tries to login into facebook through my app then i am getting error. 
  If I am logging out the account from the facebook app in iPhone, then it is working fine.</p>
  
  <p>How can I overcome this issue,Kindly help me out to overcome this.</p>
  
  <p>For reference, The code I am using is </p>
  
  <pre><code>- (void)sessionStateChanged:(FBSession *)session state:(FBSessionState) state error:(NSError *)error
  {
      switch (state) {
          case FBSessionStateOpen:
              if (!error) {
                  // We have a valid session
                  NSLog(@"User session found");
                  [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"FBFirstTime"];
                  [[NSUserDefaults standardUserDefaults] synchronize];
                  [self populateUserDetails];
  
                  if([[NSUserDefaults standardUserDefaults] boolForKey:@"FBFirstTime"])
                  {
                    }
                  else
                  {
                      NSLog(@"1st Time");
                  }
              }
              break;
          case FBSessionStateClosed:
          case FBSessionStateClosedLoginFailed:
              [FBSession.activeSession closeAndClearTokenInformation];
  
              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;
      }
  
      [[NSNotificationCenter defaultCenter] postNotificationName:FBSessionStateChangedNotification object:session];
  
      if (error) {
          UIAlertView *alertView = [[UIAlertView alloc]
                                    initWithTitle:@"Error"
                                    message:error.localizedDescription
                                    delegate:nil
                                    cancelButtonTitle:@"OK"
                                    otherButtonTitles:nil];
          [alertView show];
      }
  }
  </code></pre>
  
  <p>//</p>
  
  <pre><code>- (BOOL)openSessionWithAllowLoginUI:(BOOL)allowLoginUI {
      //    NSArray *permissions = [[NSArray alloc] initWithObjects:@"email", @"user_likes", nil];
      NSArray* permissions = [[NSArray alloc] initWithObjects:@"user_birthday",
                              @"user_about_me",
                              @"user_checkins",
                              @"user_hometown",
                              @"user_activities",
                              @"user_events",
                              nil];
      return [FBSession openActiveSessionWithReadPermissions:permissions
                                                allowLoginUI:allowLoginUI
                                           completionHandler:^(FBSession *session,
                                                               FBSessionState state,
                                                               NSError *error) {
                                               [self sessionStateChanged:session
                                                                   state:state
                                                                   error:error];
                                           }];
  }
  </code></pre>
  
  <p>//</p>
  
  <pre><code>- (void)populateUserDetails
  {
      if (FBSession.activeSession.isOpen) {
          [[FBRequest requestForMe] startWithCompletionHandler:^(FBRequestConnection *connection, NSDictionary&lt;FBGraphUser&gt; *user, NSError *error) {
              if (!error) {
                  NSThread *contactsObjectsThread = [[NSThread alloc]initWithTarget:self selector:@selector(createUserContactsObjects) object:nil];
                  [contactsObjectsThread start];
  
  
                  [activityView stopAnimating];
              }
          }];
      }
  }
  </code></pre>