我将我的iOS代码迁移到FBSDK v4 + Parse 1.7.1,我试图处理将用户链接到FB ID的情况,但它已经链接了:
Another user is already linked to this facebook id. (Code: 208, Version: 1.7.1)
用户注销和FB登录后,一切似乎都能正常工作,但每次我更改或保存当前用户或查询表时,都会遇到各种错误,例如:
Parse::UserCannotBeAlteredWithoutSessionError (Code: 206, Version: 1.7.1)
"PFKeychainStore" failed to set object for key 'currentUser'
no results matched the query (Code: 101, Version: 1.7.1)
这是我的代码:
NSArray *permisions = [NSArray arrayWithObjects:@"public_profile", @"email", @"user_friends", nil];
[PFFacebookUtils linkUserInBackground:[PFUser currentUser] withReadPermissions:permissions block:^(BOOL succeeded, NSError *error) {
if(succeeded && !error) {
//... use data
}
else {
if(error.code == 208) {
[PFUser logOut];
[PFFacebookUtils logInInBackgroundWithReadPermissions:permissions block:^(PFUser *user, NSError *error) {
//here I get a valid user and no error but...
//after this point the errors mentioned start to show up
}
}
else
//... handle other errors
}
}];
我使用Parse的自动用户,直到用户链接到FB帐户。
非常喜欢这方面的帮助,谢谢!
答案 0 :(得分:1)
添加getsInBackground会停止错误:
NSArray *permisions = [NSArray arrayWithObjects:@"public_profile", @"email", @"user_friends", nil];
[PFFacebookUtils linkUserInBackground:[PFUser currentUser] withReadPermissions:permissions block:^(BOOL succeeded, NSError *error) {
if(succeeded && !error) {
//... success
}
else {
if(error.code == kPFErrorFacebookAccountAlreadyLinked) {
[PFUser logOutInBackgroundWithBlock:^(NSError *error) {
if(!error) {
[PFFacebookUtils linkUserInBackground:[PFUser currentUser] withReadPermissions:permissions block:^(BOOL succeeded, NSError *error) {
[PFUser becomeInBackground:[[PFUser currentUser] sessionToken] block:^(PFUser *user, NSError *error) {
if(user && !error) {
// ... success
}
else {
//... handle become error
}
}];
}];
}
else {
// ... handle bad logout
}
}
else {
//... handle other errors
}
}
}];