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

In order to use consumeItem the user should purchase the item first and only than it is possible to use consumeItem

其他提示

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();
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top