2013-12-16 39 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

相关问题