Skip to main content

Use Item

Uses up the item stored in the player's Inbox.

Call Information

// Use a single item
public void ConsumeItem (string itemKey, PlayNANOODelegate callback) {}

// Use multiple items
public void ConsumeMultiItem (List<string> itemKeys, PlayNANOODelegate callback) {}

Call Information Details

ParameterDescriptionType
itemKeyItem identification keystring
itemKeysItem identification key listList<string>
callbackCommunication resultPlayNANOODelegate

Source Code

using PlayNANOO;

public class PlayNANOOExample : MonoBehaviour
{
Plugin plugin;

void Awake()
{
plugin = Plugin.GetInstance();

// Use a single item
string itemKey = "ITEM_KEY";

plugin.InboxManager.ConsumeItem(itemKey, (status, error, jsonString, values) =>
{
if(status.Equals(Configure.PN_API_STATE_SUCCESS)) {
PlayNANOO.Inbox.ItemValueModel[] items = values["Items"] as PlayNANOO.Inbox.ItemValueModel[];
foreach (PlayNANOO.Inbox.ItemValueModel item in items)
{
Debug.Log(item.item_code);
Debug.Log(item.item_count);
}
} else {
Debug.Log("Fail");
}
});

// Use multiple items
List<string> itemKeys = new List<string>();
itemKeys.Add("ITEM_KEY_1");
itemKeys.Add("ITEM_KEY_2");

plugin.InboxManager.ConsumeMultiItem(itemKeys, (status, error, jsonString, values) =>
{
PlayNANOO.Inbox.ItemValueModel[] items = values["Items"] as PlayNANOO.Inbox.ItemValueModel[];
foreach (PlayNANOO.Inbox.ItemValueModel item in items)
{
Debug.Log(item.item_code);
Debug.Log(item.item_count);
}
});
}
}

Communication Result

HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
{
"items": [
{
"item_code": "gold",
"item_count": 100
}
]
]
}

Communication Result

Data KeyDescriptionType
items.item_codeItem codestring
items.item_countItem quantityinteger