In order to use consumeItem the user should purchase the item first and only than it is possible to use consumeItem
In app billing milkman ane
-
11-07-2023 - |
문제
Every time I am trying to use
AndroidIAB.androidIAB.consumeItem("coin_stack_2");
I get : failed:4040/The item 'coin_stack_2' was not previously loaded.
==> it's happening for all of my products that I'm trying to sell as a consumeItem
I have loaded the the function below at the start of the application :
AndroidIAB.androidIAB.loadPlayerInventory();
What am I doing wrong?
해결책 2
다른 팁
AndroidIAB.androidIAB.loadPlayerInventory
is an asynchronous call, which means that you have to wait for it to finish. The full code should look similar to this:
// listen for inventory events
AndroidIAB.androidIAB.addEventListener(AndroidBillingEvent.INVENTORY_LOADED, onInventoryLoaded);
AndroidIAB.androidIAB.addEventListener(AndroidBillingErrorEvent.LOAD_INVENTORY_FAILED, onInventoryFailed);
function onInventoryLoaded(e:AndroidBillingEvent):void
{
for each(var purchase:AndroidPurchase in e.purchases)
{
trace("You own the item:"+purchase.itemId);
// this is where you'd update the state of your app to reflect ownership of the item
}
}
function onInventoryFailed(e:AndroidBillingErrorEvent):void
{
trace("Something went wrong loading inventory: "+e.text);
}
// load the player's current inventory
AndroidIAB.androidIAB.loadPlayerInventory();
제휴하지 않습니다 StackOverflow