문제

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