question

Jakob Randa avatar image
Jakob Randa asked

LoginWithCustomID windows desktop

Hallo Fellow Playfab users,

I am trying to log into PlayFab anonymously using the "PlayFabClientAPI::LoginWithCustomID" function on a windows desktop machine.

To call this function, I need to fill in the following:

LoginWithCustomIDRequest request;

request.CreateAccount = true;

request.CustomId = "????"; // What?

request.TitleId = "41538"; // The title id.

What should I fill in for CustomId. It seems that I need to provide a unique textstring myself; one that is not used on playfab.

As I have not mean of knowing which customId are already taken up on playfab on the current machine, tHis means that I need to come up with some random CustomId, then connect to PlayFab and verify that it is not already taken; and if so I need to try again with another unique identifier... This seems a bit strange and not really optimal. In extreme cases I might need to go back and forth several times.

I thought the whole idea was that PlayFab could provide such a unique id.

So,

1) Is there a way for me to ask PlayFab to give me a unique customId, instead of me trying to come up with one?

2) If I need to create one myself on a windows desktop, is there a good approach to this?

Thanks in advance,

Besides this, we are very satisfied with PlayFab compared to other similar platforms we tried out.

Kind regards,

Jakob Randa.

,

10 |1200

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

Rick Chen avatar image
Rick Chen answered

The CustomId should be unique for different accounts. And it should be provided by your device, since it is used to identify your device. You could use the PC Device Id or a GUID generated by program as the Custom Id. For example, Guid.NewGuid Method (System) | Microsoft Docs. The GUID is an acronym that stands for Globally Unique Identifier, it is highly unlikely to repeat despite there being no central GUID authority to ensure uniqueness.

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.

Jakob Randa avatar image Jakob Randa commented ·

Hi Rick

Thank you for a fulfilling answer. Will use the Guid approach then.

Kind regards,

Jakob.

0 Likes 0 ·
Peter Johnson avatar image
Peter Johnson answered

Hi, I used to do anonymous logins with DeviceID, but I discovered that some clients could not log in while others could. I detected after a while it was because their Device ID number exceeded the maximum length permitted.

I now use Custom ID. Not sure if I do it the right way, but if a user has never logged in before, my system generates them a random 24 to 48 character number, and logs them in with that number. That number is then stored locally. If they log in again and the random number exists it skips the random number generation.

If seems to provide the same sort of functionality as the NewGui system above

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.

Peter Johnson avatar image Peter Johnson commented ·

const string glyphs = "abcdef0123456789" //add the characters you want private string RandomNumber = "0"; // declare string

int charAmount = UnityEngine.Random.Range(24, 48); //set those to the minimum and maximum length of your string

         for (int i = 0; i < charAmount; i++)
         {
             RandomNumber += glyphs[UnityEngine.Random.Range(0, glyphs.Length)];
         }

         Debug.Log("Random Number is" + RandomNumber);


         PlayerPrefs.SetString("StoredRandomDeviceIDAA", RandomNumber);

This will create a random number using a to f and 0 to 9 from 24 to 48 characters

0 Likes 0 ·
Peter Johnson avatar image
Peter Johnson answered

Hi, I used to do anonymous logins with DeviceID, but I discovered that some clients could not log in while others could. I detected after a while it was because their Device ID number exceeded the maximum length permitted.

I now use Custom ID. Not sure if I do it the right way, but if a user has never logged in before, my system generates them a random 24 to 48 character number, and logs them in with that number. That number is then stored locally. If they log in again and the random number exists it skips the random number generation.

If seems to provide the same sort of functionality as the NewGui system above

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.