I am trying to grant an item to a user (non- purchase) in a Unity3D game. I see the GrantItemsToUsers in the docs but I dont see it in the API.
Is this possible? If not, what is the best way to give a user an inventory item?
Answer by Brendan · Aug 15, 2017 at 08:03 AM
There are two possible API calls you may be looking for:
https://api.playfab.com/documentation/server/method/GrantItemsToUser
https://api.playfab.com/documentation/server/method/GrantItemsToUsers
Can you check to make sure you've enabled the Server API in your project?
@Brendan Thanks, I added the Server API and now can see the Grant item code. However, I am getting an invalid parameter when using this Unity code:
publicvoidGrantItem(string itemType)
{
varrequest=newGrantItemsToUsersRequest();
request.ItemGrants=newList<ItemGrant>();
request.ItemGrants.Add(newItemGrant{PlayFabId = UserInfo.PlayerData.id});
request.ItemGrants.Add(newItemGrant{ItemId =itemType});
PlayFabServerAPI.GrantItemsToUsers(request,LogSuccess,LogFailure);
}
Am I not building the list correct?
In that code, it looks like you're adding an ItemGrant with the PlayFab ID, and separately adding another with the Item ID set. Each ItemGrant needs to have both set - can you give that a try?
How to add PayPal to a game 1 Answer
Non-receipt payment flow causes most browsers to eat the Facebook Payments pop-up 1 Answer
Is subscription IAP available for indie tier yet? 2 Answers
How can I get the custom data from my shop items? 1 Answer
Is it necessary that the price in RM matches the price in USD in the app store? 1 Answer