question

mateandor avatar image
mateandor asked

PlayFab Unity Facebook NewlyCreated,PlayFab Unity Facebook NewlyCreated false

hello!

Im new with PlayFab and i try to login with facebook. Everything works fine, but when i check the newlycreated i got every time false.

What i do wrong?

    private void OnFacebookLoggedIn(ILoginResult result)
    {
        // If result has no errors, it means we have authenticated in Facebook successfully
        if (result == null || string.IsNullOrEmpty(result.Error))
        {
            SetMessage("Facebook Auth Complete! Access Token: " + AccessToken.CurrentAccessToken.TokenString + "\nLogging into PlayFab...");


            /*
             * We proceed with making a call to PlayFab API. We pass in current Facebook AccessToken and let it create 
             * and account using CreateAccount flag set to true. We also pass the callback for Success and Failure results
             */
            PlayFabClientAPI.LoginWithFacebook(new LoginWithFacebookRequest { CreateAccount = true, AccessToken = AccessToken.CurrentAccessToken.TokenString },
                OnPlayfabFacebookAuthComplete, OnPlayfabFacebookAuthFailed);


            
        }
        else
        {
            // If Facebook authentication failed, we stop the cycle with the message
            SetMessage("Facebook Auth Failed: " + result.Error + "\n" + result.RawResult, true);
        }
    }


    // When processing both results, we just set the message, explaining what's going on.
    private void OnPlayfabFacebookAuthComplete(LoginResult result)
    {
        SetMessage("PlayFab Facebook Auth Complete. Session ticket: " + result.SessionTicket);


        // HA MOST KÉSZÜLT
        if (result.NewlyCreated)
        {
            go_firstLogin.SetActive(true);
        }
        else
        {
            go_bent.SetActive(true);
        }


       
    }
,

Hello!

Im new with PlayFab and I try the facebook login. I need to see the user is new or not.

Im try with this code but every time the NewlyCreated is false.

What i do wrong?

    private void OnFacebookLoggedIn(ILoginResult result)
    {
        // If result has no errors, it means we have authenticated in Facebook successfully
        if (result == null || string.IsNullOrEmpty(result.Error))
        {
            SetMessage("Facebook Auth Complete! Access Token: " + AccessToken.CurrentAccessToken.TokenString + "\nLogging into PlayFab...");


            /*
             * We proceed with making a call to PlayFab API. We pass in current Facebook AccessToken and let it create 
             * and account using CreateAccount flag set to true. We also pass the callback for Success and Failure results
             */
            PlayFabClientAPI.LoginWithFacebook(new LoginWithFacebookRequest { CreateAccount = true, AccessToken = AccessToken.CurrentAccessToken.TokenString },
                OnPlayfabFacebookAuthComplete, OnPlayfabFacebookAuthFailed);


            
        }
        else
        {
            // If Facebook authentication failed, we stop the cycle with the message
            SetMessage("Facebook Auth Failed: " + result.Error + "\n" + result.RawResult, true);
        }
    }


    // When processing both results, we just set the message, explaining what's going on.
    private void OnPlayfabFacebookAuthComplete(LoginResult result)
    {
        SetMessage("PlayFab Facebook Auth Complete. Session ticket: " + result.SessionTicket);


        // HA MOST KÉSZÜLT
        if (result.NewlyCreated)
        {
            go_firstLogin.SetActive(true);
        }
        else
        {
            go_bent.SetActive(true);
        }


       
    }
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
brendan avatar image
brendan answered

The NewlyCreated flag is set to false in the response because the player account wasn't created in that login call. Bear in mind that the "core" of the player account - the part with the credentials - is bound to your Publisher ID. So, when you create a player using a set of credentials in one game, signing into another game in your studio (all titles in your studio have the same Publisher ID by default) signs the player into that same account, just with distinct title data (player data, inventory, stats, etc.). That's why you have the same PlayFab ID for the user across those games, and it's how we give you the ability to share player data between games, using player publisher data.

5 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

mateandor avatar image mateandor commented ·

Thanks for the a answer!

I Try with another Facebook account and the newlycreated flag works fine!

But if I delete the player (in dashboard) and try to sign in again, the flag is false.

Why is this? Can I delete the player?

0 Likes 0 ·
mateandor avatar image mateandor commented ·

Thanks for the answer!

I Try with another facebook account and the newlycreated flag works fine!

But if i delete the user in dashboard, the newlycreated is false.

Why is this? Can i delete the plyer?

0 Likes 0 ·
brendan avatar image brendan mateandor commented ·

Think of the player account as being in two parts - the credentials and player publisher data live at the Publisher ID level, while all the title-specific info lives at the Title ID level. When you delete the player, the only thing you're deleting is the part associated with the Title ID. That way, if you're testing across many Title IDs, you can safely delete the player from one without impact it in the others. If you want to use the Facebook account with a new PlayFab ID, you should log into the player account it's linked to and use the UnlinkFacebookAccount API call.

0 Likes 0 ·
mateandor avatar image mateandor commented ·

Okay! Thats very good!

But when I create a plyer like this way a (whith Facebook), the player not have displayname, password just the e-mail.

So when the player sign in with Facebook I check the newlycreated and if true i show a panel when the player can add the name.

This is a bad way?

Im very new with playfab and dont know What is the good way to register a new player.

I thinking on a register form (playername, password, e-mail), but this way i open a way to bulk registration. Or playfab can use e-mail verificaition?

0 Likes 0 ·
brendan avatar image brendan mateandor commented ·

If you're going to allow players to enter their own display names, then you can add that to your game flow anywhere you like - just use the UpdateUserTitleDisplayName call when you need to.

If you're going to go with email/password for your login system though, the good news is that we'll be providing built-in email options (including email verification) shortly - keep an eye on our blog page for more info on that.

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.