2013-12-16 35 views
0

我正在實施解析/ Facebook登錄爲iOS和它運作良好 - 我用我自己的FB用戶登錄,一切都很好。使用不同的帳戶與解析和FB登錄

但是現在我想從一個不同的FB用戶 - 測試人員的帳戶登錄到我的iOS應用程序。這是我做過什麼:

  1. 又到我的iPhone我的FB申請,註銷,並與我的測試賬號再次登錄。

  2. 回到我的iOS/Parse應用程序,並嘗試使用Facebook登錄。 結果是我用我自己的帳戶登錄了!

我卸載了應用程序,並從xCode重新運行它,使用Facebook登錄 - 我又重新使用自己的帳戶。

無論我做什麼,我都會回到自己的賬戶。它看起來像Parse或FB,以某種方式緩存我的信息。我如何取消緩存以重新開始?

這是我的登錄方法:

- (void)loginWithFB { 
    NSArray *permissionsArray = @[ @"user_about_me", @"user_relationships", @"user_birthday", @"user_location"]; 

    // Login PFUser using facebook 
    [PFFacebookUtils logInWithPermissions:permissionsArray block:^(PFUser *user, NSError *error) { 
    [_activityIndicator stopAnimating]; // Hide loading indicator 

    if (!user) { 
     if (!error) { 
      NSLog(@"Uh oh. The user cancelled the Facebook login."); 
      UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Log In Error" message:@"Uh oh. The user cancelled the Facebook login." delegate:nil cancelButtonTitle:nil otherButtonTitles:@"Dismiss", nil]; 
      [alert show]; 
     } else { 
      NSLog(@"Uh oh. An error occurred: %@", error); 
      UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Log In Error" message:[error description] delegate:nil cancelButtonTitle:nil otherButtonTitles:@"Dismiss", nil]; 
      [alert show]; 
     } 
    } else if (user.isNew) { 
     NSLog(@"User with facebook signed up and logged in!"); 
     AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate]; 
     appDelegate.window.rootViewController = appDelegate.tabBarController; 
     [appDelegate.tabBarController setSelectedIndex:3]; 
     [self.navigationController pushViewController:[[MyTrack alloc] init] animated:YES]; 
    } else { 
     NSLog(@"User with facebook logged in!"); 

     FBRequest *request = [FBRequest requestForMe]; 
     [request startWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error) { 
      if (!error) { 
       NSString *facebookUsername = [result objectForKey:@"username"]; 
       [PFUser currentUser].username = facebookUsername; 
       [[PFUser currentUser] saveEventually]; 
       NSLog(@"Welcome Screen I am %@", [[PFUser currentUser] username]); 
      } else { 
       NSLog(@"Error getting the FB username %@", [error description]); 
      } 
     }]; 


     AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate]; 
     appDelegate.window.rootViewController = appDelegate.tabBarController; 
     [appDelegate.tabBarController setSelectedIndex:0]; 
    } 
}]; 

    [_activityIndicator startAnimating]; // Show loading indicator until login is finished 

} 
+0

你還會調用'當前用戶logOut'? – Wain

+0

是的,我喜歡。作爲一項測試,我甚至嘗試將[PFUser logOut]放在這個方法的開頭,但沒有運氣。 – Eddy

回答

0

請嘗試這個用戶註銷時

[FBSession.activeSession close]; 
[FBSession.activeSession closeAndClearTokenInformation]; 
FBSession.activeSession = nil; 
+0

我做到了。現在當我再次登錄時,我得到這個:FBSDKLog:-1059155737不是有效的FBSessionLoginBehavior。忽略公開呼叫。用戶仍然是我自己的,而不是測試人員。 – Eddy

相關問題