question

webmaster avatar image
webmaster asked

Can't save duplicate displayName

We are trying to use the displayName property on Playfab to store our player's handle. We noticed a weird behavior, and also a question:

1) I was under the impression that the system would allow for duplicate displayNames. But I noticed that when we call PlayFab.AdminModels.UpdateUserTitleDisplayNameRequest() to set an account's displayName to the same as another, we get back a failure with the message "Invalid input parameters". Can you confirm if this is the correct behavior?

2) If the system does restrict displayNames to be unique, how do we check to see if a particular display name is already in use?

3) Does Playfab provide anything that can help us check the displayname that players choose to make sure the choices are appropriate?

thx!

apisAccount Management
10 |1200

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

brendan avatar image
brendan answered

By default, Title Display Name must be unique. You can change that for your title to allow it to be non-unique via the Settings->API Features in your title in the PlayFab Game Manager, but please note that doing so means you won't be able to look up players by Title Display Name in the API calls where that's an option.

When you get the "Invalid input parameters", you should check the Error Details in the response, as that normally contains specifics on what the issue was, and with which parameter.

The easiest way to check if a Title Display Name is taken is to try to set it for the player, either via a registration call or UpdateUserTitleDisplayName. If the user is signed in, you could potentially also use GetAccountInfo if you haven't set your title to allow duplicate names, but if you don't actually need that player's info, it would be simpler to just use UpdateUserTitleDisplayName.

And for "appropriate" names, we do provide access to Community Sift via our Add-ons Marketplace (https://playfab.com/add-ons/community-sift/), which can be used to help prevent inappropriate names from being used in your title.

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

webmaster avatar image webmaster commented ·

Thanks for the quick response!

0 Likes 0 ·
webmaster avatar image webmaster commented ·

@Brendan - I think I just ran into a bug. We are using the UnitySDK, and calling PlayFab.AdminModels.UpdateUserTitleDisplayNameRequest() to update displayName. When we try to update the displayname with the an existing displayName, according to the documentation, we should be getting a NameNotAvailable error code (https://api.playfab.com/documentation/admin/method/UpdateUserTitleDisplayName), but instead, we are still getting the InvalidParams ErrorCode. We are using DCA2 title, and tested with my displayname "akao".

0 Likes 0 ·
webmaster avatar image webmaster webmaster commented ·

Oh, and the API does work flawlessly when we make the same call with a brand new displayName that's not in use.

0 Likes 0 ·
brendan avatar image brendan webmaster commented ·

Can you let me know your specific repro steps? When I call UpdateUserTitleDisplayName, whether from Client or Admin API set, I get the expected "not available" error response when I try to set the player's display name to one that's already taken (unless it's the name the user in question already has, in which case the response is "OK", since there's no change).

0 Likes 0 ·
webmaster avatar image
webmaster answered

@Brendan Here is a test code that demonstrates the problem. The code is for Unity using Unity SDK.

using System;
using System.Collections.Generic;
using UnityEngine;
using System.Collections;
using PlayFab;
#if ENABLE_PLAYFABSERVER_API
using PlayFab.ServerModels;
using System.Linq;
#endi

public class PlayFabTestServer : MonoBehaviour {
    public const int MAX_TRY_COUNT = 5;
    void Awake() {
        PlayFabSettings.TitleId = "DCA2";
        #if ENABLE_PLAYFABSERVER_API
        PlayFabSettings.DeveloperSecretKey = "FOOBAR";
        #endif
    }



    /// <summary>
    /// Saves the Display Name of the player. 
    /// </summary>

    public void SavePlayerDisplayName(string playfabId, string name, Action<string> onSuccess, Action<PlayFabErrorCode, string> onFailure) {

        #if ENABLE_PLAYFABSERVER_API
        PlayFabAdminAPI.UpdateUserTitleDisplayName(new PlayFab.AdminModels.UpdateUserTitleDisplayNameRequest {
            PlayFabId = playfabId,
            DisplayName = name
        }, res => {
            if (onSuccess != null)
                onSuccess(res.DisplayName);
        }, err => {
            if (onFailure != null){
                onFailure(err.Error, err.ErrorMessage);
            }
        });
        #endif
    }

    void Start() {

        // duplicate user name
        SavePlayerDisplayName ("BF2972B14DD761CE", "akao", 
            name => {
                Debug.Log ("** Success: " + name);
            },
            (errCode, errMsg) => {
                Debug.Log ("** Failed: " + errCode + " " + errMsg);
            }
        );
            

        // new user name
        SavePlayerDisplayName ("BF2972B14DD761CE", "akao10", 
            name => {
                Debug.Log ("** Success: " + name);
            },
            (errCode, errMsg) => {
                Debug.Log ("** Failed: " + errCode + " " + errMsg);
            }
        );
    }
}

In our system, we already have another player named "akao" and we tried to name a player to that name, then tries to name him to "akao10". When we run the code, we get:

** Failed: InvalidParams Invalid input parameters

** Success: akao10

When we would have expected the first failure to indicate that the displayname isn't available.

playfabtestservercs.zip


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

brendan avatar image brendan commented ·

Yes, the first call, attempting to use a pre-existing display name, should result in NameNotAvailable. I'll open a bug on that.

0 Likes 0 ·
webmaster avatar image webmaster commented ·

@Brendan thanks for the quick response!

0 Likes 0 ·
webmaster avatar image webmaster commented ·

@Brendan Any ETA on the bug?

0 Likes 0 ·
brendan avatar image brendan webmaster commented ·

Sorry, but we can't really provide a date for something until it's in active development, since our schedule can change at any time. For issues like this, where there is a workaround (the display name isn't accepted, so no damage is done to existing accounts, so the way to handle it is that if an InvalidParams comes back, and the error details doesn't specify which parameter is invalid, to ask the player to try a different name), they're not prioritized as highly, so it may take some time for them to get into the schedule.

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.