0

I am using Facebook as one option to create a user account for my iOS app.

I am using createUserIfNeeded to create a new user account with stackmob. But how do I check if an account was already created previously and this is not a new account? (i.e stack mob is just logging in an existing user)

I need this information as if a new user was just created, I want to create a new user profile. Otherwise the user will obviously already have a profile and I won't want to create another for the same user.

[self.client loginWithFacebookToken:FBSession.activeSession.accessTokenData.accessToken createUserIfNeeded:YES usernameForCreate:user.username onSuccess:^(NSDictionary *result)
{
        NSLog(@"Logged in with StackMob");

        } onFailure:^(NSError *error) {

        NSLog(@"Error: %@", error);
    }];

}

Sarah92
  • 671
  • 4
  • 12
  • 29
  • This API Method is just creating a new user if it didn't exist before.. so no worries on your side.. if the user existed he will just be logged in – lukaswelte Feb 08 '14 at 17:15
  • but how do I check when I need to create a new user profile for the user account? @lukaswelte ? – Sarah92 Feb 08 '14 at 17:17

1 Answers1

0

Here is what I will do:

Try to log in directly. Catch any error. If there is an error related to user, then the user is not signed. Otherwise just take the fact that the user has been created.

Btw, why do you want to know this information? In my own implementation I just use the facebook returned object and sign in use loginWithFacebookToken. It doesn't seem to bother me if it is new or not, because I will sync everything and do initialization the same way as a new user signed in.

P.S. StackMob is closing down. Don't spend too much time on it.

Lei Zhang
  • 500
  • 4
  • 15