question

woojoo avatar image
woojoo asked

how to check if displayname setted

how can i get user's displayname??

or boolean if displayname setted.

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

From the client: https://api.playfab.com/Documentation/Client/method/GetAccountInfo

From Cloud Script or a custom game server: https://api.playfab.com/Documentation/Server/method/GetUserAccountInfo

The DisplayName is part of the UserTitleInfo in the response.

6 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.

woojoo avatar image woojoo commented ·

Thanks for quick reply!!

I'm trying to check if user's displayname is setted on login and pop up the setting menu.

so.. no possible ways to get name from loginresult?

0 Likes 0 ·
brendan avatar image brendan woojoo commented ·

All login API calls include InfoRequestParameters, which lets you request available information for the player account, including the Account Info you can query from GetAccountInfo. So if your requirement is to get the info at login time, that would be the way to go.

0 Likes 0 ·
woojoo avatar image woojoo commented ·

thank you Brendan!

In Unity

LoginResultCallback(PlayFab.ClientModels.LoginResult result){

print(result.InfoResultPayload.AccountInfo.TitleInfo.DisplayName);

}

0 Likes 0 ·
woojoo avatar image woojoo commented ·

I kept trying with the code above. unfortunately , giving nullexception error

inside login result callback

        print("playfab ID = " + result.PlayFabId);

        if (result.InfoResultPayload.AccountInfo.TitleInfo.DisplayName == "")

        {

            print("Should SetDisplay Name");

        }

result.InfoResultPayload.AccountInfo.TitleInfo.DisplayName

is giving me nullreferenceexception error...

0 Likes 0 ·
brendan avatar image brendan woojoo commented ·

What are you passing in for the InfoRequestParameters input to the call? Also, are you sure that the player in question has logged into the specific Title ID? It's always a good idea to check objects before dereferencing them, and to handle cases where they are null. For example, if the player has never logged into the specific Title ID in question, there will be no TitleInfo for that player, making that part of the returned data null. Alternately, if the InfoRequestParameters didn't have GetUserAccountInfo set to true, no AccountInfo would be returned, making it null.

0 Likes 0 ·
woojoo avatar image woojoo brendan commented ·

oh..

i thought GetTitleData is the one.

added GetUserAccountInfo and, works like a magic now Thanks!!

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.