question

Kim Strasser avatar image
Kim Strasser asked

PlayFab user registration always fails

I want that a player can create a new PlayFab account but I always get an error message in this line:

if (task.Result.Result != null)

What is wrong with my code? I set the TitleId "BFD0A" in my code, but it's still not working.

I use Xamarin, not Unity.

  RegisterPlayFabAccount();

  private void RegisterPlayFabAccount()
  {
      var request = new RegisterPlayFabUserRequest { TitleId = "BFD0A", RequireBothUsernameAndEmail = true, Email = KeyboardTextEmail, Username = KeyboardTextUsername, Password = KeyboardTextPassword };
      var registerTask = PlayFabClientAPI.RegisterPlayFabUserAsync(request);
      registerTask.ContinueWith(OnPlayFabRegisterAccountComplete);
  }

  private void OnPlayFabRegisterAccountComplete(Task<PlayFabResult<RegisterPlayFabUserResult>> task)
  {
      var newLabel = "Unknown failure";
      if (task.Result.Result != null)
      {
          newLabel = "Congratulations, Registration successful!";
      }
      if (task.Result.Error != null)
      {
          newLabel = "Something went wrong with your Registration.\n"
                    + "Here's some debug information:\n"
                    + task.Result.Error.GenerateErrorReport();
      }
      lock (_myLabelText)
      {
          _myLabelText = newLabel;
      }
  }


Authentication
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

·
Seth Du avatar image
Seth Du answered

According to the official Xamarin tutorial: https://docs.microsoft.com/en-us/gaming/playfab/sdks/xamarin/quickstart, you need to add this line before the API call, and make another attempt.

PlayFabSettings.TitleId = " BFD0A";

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.