2
votes

I'm using Parse 1.7.1 for iOS and I am trying to sign up a user. I chose to let the user interact with the app before I force the sign up / login process. The problem is that as soon as I call signUp the session object disappears from the server and causes any subsequent calls to return error 209.

Here's some code:

AppDelegate:

[PFUser enableAutomaticUser];
[[PFUser currentUser] incrementKey:@"runCount"];
[[PFUser currentUser] saveInBackground];

When I check the Parse Core console I can see a valid User & Session.

MyController:

PFUser *user = [PFUser currentUser];
if (! user) {
    user = [PFUser user];
}
user.email = @"[email protected]";
user.password = @"somepassword";
user.username = @"whatever";
// I also tried Save instead of signUpInBackground... same result
[user signUpInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
    if (succeeded) {
        NSLog(@"Success signing up");
    }
    else {
        NSLog(@"Error %@", [error localizedDescription]);
    }
}];

When I check the console there is an updated user but there is no Session anymore.

Any other API call

[Error]: invalid session token (Code: 209, Version: 1.7.1)

Despite the fact that the callback returns success as soon as I try to interact with the Parse API I get a 209, invalid session token. This is fair enough, since the session object is not present in the console.

Does anyone know what I am doing wrong?

Note: this a brand new app (not affected by the change made by Parse on the 25th of March)/.

2
Did you try to use PFAnonymousUtils logInWithBlock? instead of enableAutomaticUserkabarga
Yes, I have. Any subsequent "save" or "sign up" calls cause the server side session object to disappear.nicktmro

2 Answers

1
votes

I have raised this as a bug with Facebook and they are fixing it in 1.7.3

Here's the conversation I had with them.

0
votes

Create button with selector -signUpSelector. And need implement this code:

-(void)signUpSelector
  [PFUser becomeInBackground:@"session-token-here" block:^(PFUser *user, NSError *error) {
PFUser *newUser = nil;
  if (error) {
  newUser = [PFUser user];
   } else {
   newUser = user;
  }
  user.email = @"[email protected]";
  user.password = @"somepassword";
  user.username = @"whatever";

  [user signUpInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
   if (succeeded) {
    NSLog(@"Success signing up");
    }
   else {
    NSLog(@"Error %@", [error localizedDescription]);
    }
   }];

}];