question

Developer Jake avatar image
Developer Jake asked

Display the user’s display name upon logging in,

1 comment
10 |1200

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

Developer Jake avatar image Developer Jake commented ·

(Sorry, pressed return and it instantly sent my question.) I’m trying to create a system that logs you in, but says “Welcome” + userDisplayName, except I am not sure how to reference the user’s title display name. I’ve read https://community.playfab.com/questions/358/206712347-show-display-name.html however, it’s given me a response of null each time I use those scripts. Please help

0 Likes 0 ·
JayZuo avatar image
JayZuo answered

GetAccountInfo should be able to get the player's display name. But you need to make sure this player has set the display name. And the display name is not returned in "GetAccountInfoResult.AccountInfo.Username" anymore. Instead, we should use "GetAccountInfoResult.AccountInfo.TitleInfo.DisplayName". Thus, the code should be something like:

public void OnGetUsernameResult(GetAccountInfoResult result)
{
   theLoginScreen.loginStatus.text = "Welcome " + result.AccountInfo.TitleInfo.DisplayName;
}

Besides, as you want to get display name upon logging in, you can just add an "InfoRequestParameters" in you login request. Using LoginWithCustomID for example, the request would like:

{
    "CustomId": "{
                {CustomId}}",
    "CreateAccount": false,
    "TitleId": "{
                {TitleId}}",
    "InfoRequestParameters": {
        "GetUserAccountInfo": true
    }
}

And we can get the display name with "LoginResult.InfoResultPayload.AccountInfo.TitleInfo.DisplayName". For more details about the construct, please check API's response.

10 |1200

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

Developer Jake avatar image
Developer Jake answered

Alright thanks. Everything seems to be working

10 |1200

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

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.