question

ashemez@outlook.com avatar image
ashemez@outlook.com asked

Xamarin couldn't login with LoginWithCustomIDAsync

Hello,

I set the PlayFabSettings.TitleId and tried to log in with the method below but api doesn't login. C# sdk's LoginWithCustomIDAsync doesn't create a player for given customID I guess?

public async void Login(string titleId, string player_id)
{
   if (!PlayFabClientAPI.IsClientLoggedIn())
   {

      LoginWithCustomIDRequest request = new LoginWithCustomIDRequest()
      {
         TitleId = titleId,
         CreateAccount = true,
         CustomId = player_id,
      };
      await PlayFabClientAPI.LoginWithCustomIDAsync(request);
   }
}

Thanks

 

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

Well, you are correct that you need to provide the CustomId in this call - the intent being that you have a custom identifier you've created for the player, that you want to use. But if you're passing in a valid string (that is, CustomId is not null) in the call, you should be signed into an account. Can you let us know specifically what the parameter values are you're passing in, and the response you're getting back (with the errorDetails)?

10 |1200

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

ashemez@outlook.com avatar image
ashemez@outlook.com answered

Hello,

OK it is working now. But I am sure at first I tried a few times and it didn't login. I gave a random string something like "sdfsdfsdf" to CustomID parameter, title id is 108. That is all. Now it logins. But now User data request is not answering :)

I don't get any error but just freezed the game screen. Here is how I call the PlayFabClientAPI.UpdateUserDataAsync method:

public async void SaveGameData(GameData gameData)
{
   if (PlayFabClientAPI.IsClientLoggedIn())
   {
      UpdateUserDataRequest request = new UpdateUserDataRequest();
      request.Data = new System.Collections.Generic.Dictionary<string, string>();
      request.Data.Add("player_id", gameData.player_id);
      request.Data.Add("levelID", gameData.levelID.ToString());
      request.Data.Add("xp", gameData.xp.ToString());
      ...

      await PlayFabClientAPI.UpdateUserDataAsync(request);
   }
}

10 |1200

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

ashemez@outlook.com avatar image
ashemez@outlook.com answered

Hi again

 

It saves user data as well. Sorry I am new to Playfab.com.  I guess it was awaiting too long while debugging in the editor.

 

Thanks

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

Glad to hear it's working for you. If you ever get a failure to log in, you should check the error details, to see what the issue was. All failed API calls will result in an error message containing more info that you can process.

Now, for your data call, I would highly recommend this article: https://msdn.microsoft.com/en-us/magazine/jj991977.aspx. Looking at your code snippet, I believe what you really want here is an async Task - not async void. Also, if you're calling Wait on the SaveGameData call in your main thread, that would explain the hang you're seeing.

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

Ah, I see. Well, glad to hear it's all working for you - let us know if you run into other issues.

10 |1200

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

ashemez@outlook.com avatar image
ashemez@outlook.com answered

Thanks for the async method usage. I'll keep that in mind. 

Regards

 

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.