你的其他应用程序是否使用Parse作为后端?
PFFacebookUtils中存储的用户状态与从FBLoginView返回的用户不同。
如果你的代码看起来像这样:
#pragma mark FBLoginViewDelegate {
- (void)loginViewFetchedUserInfo:(FBLoginView *)loginView
user:(id<FBGraphUser>)user {
NSLog(@"User: %@", user);
if (![PFFacebookUtils isLinkedWithUser:user]) {
[PFFacebookUtils linkUser:user permissions:nil block:^(BOOL succeeded, NSError *error) {
if (succeeded) {
NSLog(@"Woohoo, user logged in with Facebook!");
}
}];
}
}
那么您当前正在链接一个与PFUser不兼容的Facebook用户对象。我建议使用FBLoginView返回的数据,并以常规方式创建一个解析用户:
#pragma mark FBLoginViewDelegate {
- (void)loginViewFetchedUserInfo:(FBLoginView *)loginView
user:(id<FBGraphUser>)user {
NSLog(@"User: %@", user);
NSString *username = user[@"email"];
NSString *password = user[@"id"];
[PFUser logInWithUsernameInBackground:username password:password block:^(PFUser *user, NSError *error) {
NSLog(@"User: %@", user);
if (error.code == 101) {
PFUser *user = [PFUser user];
user.username = username;
user.password = password;
[user signUpInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
NSLog(@"Error: %@", error);
}];
}
}];
}
现在,[PFUser currentUser]将返回一个Parse用户对象,该对象是基于您的Facebook登录创建的。如果应用程序被删除/重新安装,则下次用户进入应用程序时,FBLoginView将返回一个userid,该userid将用于作为现有用户登录到解析中。
编辑:我遇到的类似问题是,如果我的手机在iOS设置中集成了Facebook,则使用FBLogin、PFFacebookUtils和任何其他最近的Facebook应用程序登录会出现问题。这似乎与苹果集成Facebook和新的Facebook SDK有关。这很烦人,但我目前必须告诉我的用户从设置中删除他们的Facebook信息,然后他们可以使用PFFacebookUtils或上述过程进行登录。希望这个问题能尽快得到解决。