samedi 18 avril 2015

Errors after PFUser logOut and PFFacebookUtils logInInBackgroundWithReadPermissions

I migrated my iOS code to FBSDK v4 + Parse 1.7.1 and I'm trying to handle the case of linking a user to a FB ID but it's already linked:



Another user is already linked to this facebook id. (Code: 208, Version: 1.7.1)


Everything seems to work fine after user logout and FB login but every time I alter or save the current user, or query a table, I get various errors such as:



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)


Here is my code:



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
}


}];


I use Parse's automatic user until a user is linked to a FB account.


Would love some help about this, thanks!


Aucun commentaire:

Enregistrer un commentaire