I am going to add multiple items to player's inventory, by PlayFabEconomyAPI.ExecuteInventoryOperation
but it is always response "NotAuthorizedByTitle", not sure what is wrong with it, here is my codes:
[System.Serializable]
public struct Reward
{
public string itemFriendlyName;
public int itemAmount;
}
private void ExecuteInventoryOperations(UserAccountInfo accountInfo)
{
var ops = new List<InventoryOperation>();
for (int i = 0; i < rewards.Length; ++i)
{
ops.Add(new InventoryOperation()
{
Add = new AddInventoryItemsOperation()
{
Item = new InventoryItemReference()
{
AlternateId = new AlternateId()
{
Type = "FriendlyId",
Value = rewards[i].itemFriendlyName,
}
},
Amount = rewards[i].itemAmount,
},
});
}
PlayFabEconomyAPI.ExecuteInventoryOperations(new ExecuteInventoryOperationsRequest()
{
Operations = ops,
Entity = new EcoEntityKey
{
Id = accountInfo.TitleInfo.TitlePlayerAccount.Id,
Type = accountInfo.TitleInfo.TitlePlayerAccount.Type
}
}, response =>
{
if (particlesPrefab != null)
{
GameObject particles = Instantiate(particlesPrefab, PlayerEntity.Mine.transform.position, Quaternion.identity);
Destroy(particles, particleEffectDuration);
}
}, error =>
{
Debug.LogError(error.Error);
AppInstance.Instance.ShowErrorMessageDialog(LanguageManager.GetText(error.ErrorMessage));
});
}
But it is fine for PlayFabEconomyAPI.AddInventoryItems with similar parameters (enity, item alternate id) so I have to use it for now.