- Home /
How can I check if fb user is new in my database?(Parse+fb)
Hi, I would like to check if fb player (which is currently logging) is new in my database. I heard something about 'isNew()'but I don't know how I should use that. This is an example:
private void ParseSync (){
Task logInTask = ParseFacebookUtils.LogInAsync (FB.UserId, FB.AccessToken, FB.AccessTokenExpiresAt);
//if( this is his first time in game/in my database )
// do something
// else
// do other stuff
}
I asked on 'pharse' forum, but I have a feeling that forum is dead :/ :P Thanks!
Answer by MichiealO · Aug 08, 2014 at 01:20 PM
// show the signup or login screen
Task<ParseUser> logInTask = ParseFacebookUtils.LogInAsync(userId, accessToken, tokenExpiration);
if (user.ContainsKey ("NotNew") == false) // going assume that this is a new user... so.. create them.
CreateParseUser();
if (!ParseFacebookUtils.IsLinked(user)) {
// links the defined ParseUser to the selected FB user...
Task linkTask = ParseFacebookUtils.LinkAsync(user, userId, accessToken, tokenExpiration);
}
... Then in the create user section, make sure to add:
if (user.ContainsKey("NotNew")==false) //checks to see if the key exists in the current user...
user.Add("NotNew",1); // adds the Key to the user, and sets it to 1.
This is what I used, I seems to work... The logic behind it is this: when you log them in, Parse automatically does Login/Signup... making the successful result into an existing "CurrentUser". And, if the "NotNew" field is an integer, that gets set to 1 (a true value) when you do your NewUser Code. Then, regardless of "if found" or not, it will tell you whether the currently signed in user is new. [false == new, true == notnew]...
I apologize if it's not 100% perfect, I'm still a tad shaky on the ParseUser stuff...
I hope that this helps or at least points you in the right direction, and if it does, can you up-vote my answer?
Your answer
Follow this Question
Related Questions
A node in a childnode? 1 Answer
unity + php get Authentication 0 Answers
Invalid Encoding Specification Xml 1 Answer
Parse Online Storage fails to communicate -1 Answers
CG Shader Properties Parse Error 1 Answer