question

filipzielinski avatar image
filipzielinski asked

How to list all the groups associated with player entity using LoginResult?

Hi,

I want to list all the groups which player is a part of.

LoginResult contains ClientAPI entitykey but ListMembershipRequest in PlayFabGroupsApi.ListMembership call require GroupsModel.EntityKey.

How should I retrieve clients groups?

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

·
JayZuo avatar image
JayZuo answered

Since you want to list all the groups associated with the player, then the GroupsModel.EntityKey used in PlayFabGroupsApi.ListMembership method is exactly the same entity key returned in LoginResult. What you need to do here is manually wrap it into GroupsModel.EntityKey like the following:

//TitlePlayerEntityKey is the property that stores entitykey returned by LoginResult.EntityToken.Entity
PlayFabGroupsAPI.ListMembership(new PlayFab.GroupsModels.ListMembershipRequest { Entity = new PlayFab.GroupsModels.EntityKey { Id = TitlePlayerEntityKey.Id, Type = TitlePlayerEntityKey.Type } },
    result =>
    {
        foreach (var group in result.Groups)
        {
            Debug.Log(group.Group.Type + " : " + group.Group.Id + " - " + group.GroupName);
        }
    },
    error => { Debug.LogError(error.GenerateErrorReport()); });
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.