Ios 使用其他帐户使用Parse和FB登录
我正在为iOS实现Parse/Facebook登录,它工作得很好——我用自己的FB用户登录,一切都很好 但是现在我想从一个不同的FB用户登录到我的iOS应用程序-一个测试人员的帐户。这就是我所做的:Ios 使用其他帐户使用Parse和FB登录,ios,facebook-graph-api,parse-platform,facebook-sdk-3.0,Ios,Facebook Graph Api,Parse Platform,Facebook Sdk 3.0,我正在为iOS实现Parse/Facebook登录,它工作得很好——我用自己的FB用户登录,一切都很好 但是现在我想从一个不同的FB用户登录到我的iOS应用程序-一个测试人员的帐户。这就是我所做的: 转到我的iPhone上的FB应用程序,注销,然后使用我的测试帐户再次登录 返回到我的iOS/Parse应用程序并尝试使用Facebook登录。 结果是我用自己的帐户登录了 我卸载了这个应用程序,然后从xCode重新运行它,用Facebook登录——我又重新使用了我自己的帐户 不管我做什么,我总是回到
- (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
}
请在注销时尝试此操作
[FBSession.activeSession close];
[FBSession.activeSession closeAndClearTokenInformation];
FBSession.activeSession = nil;
您是否曾经对当前用户调用过
logOut
?是的,我调用过。作为一个测试,我甚至试着在这个方法的开头放上[PFUser logOut],但没有成功。我做到了。现在,当我再次登录时,我发现:FBSDKLog:-1059155737不是有效的FBSessionLoginBehavior。忽略打开的呼叫。用户仍然是我自己的,而不是测试人员的。