question

AJ avatar image
AJ asked

How can I get the first ContactEmailAddress?

I can update the contactact email address successfully but I can't get it after that to show on the relevant text field. Here is my code:

public void GetPlayerProfileData()
    {
        var request = new GetPlayerProfileRequest
        {
            PlayFabId = playFabId,
            ProfileConstraints = new PlayerProfileViewConstraints()
            {
                ShowContactEmailAddresses = true
            }
    };
        PlayFabClientAPI.GetPlayerProfile(new GetPlayerProfileRequest(), OnGetPlayerProfileSuccess, OnError);
    }
    void OnGetPlayerProfileSuccess(GetPlayerProfileResult result)
    {
        var contactEmailAddress = result.PlayerProfile.ContactEmailAddresses[0].EmailAddress;
        _contactEmailEntered.text = contactEmailAddress;
        PlayerPrefs.SetString("ContactEmail", contactEmailAddress);
        PlayerPrefs.Save();
    }
Player Data
2 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.

Ivan Cai avatar image Ivan Cai ♦ commented ·

In your script inspector,does the Contact Email Entered tab have a corresponding gameobject(text)?

0 Likes 0 ·
AJ avatar image AJ Ivan Cai ♦ commented ·

Yes. I get a NullReferenceExeption pointing to line

var contactEmailAddress = result.PlayerProfile.ContactEmailAddresses[0].EmailAddress;

0 Likes 0 ·

1 Answer

·
Ivan Cai avatar image
Ivan Cai answered
PlayFabClientAPI.GetPlayerProfile(new GetPlayerProfileRequest(), OnGetPlayerProfileSuccess, OnError);

Change to

PlayFabClientAPI.GetPlayerProfile(request, OnGetPlayerProfileSuccess, OnError);
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.

AJ avatar image AJ commented ·

Yes, it works now. Such a silly mistake :) Thank you very much, Ivan!

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.