每次我尝试使用
AndroidIAB.androidIAB.consumeItem("coin_stack_2");
我得到:失败:4040 /先前未加载“coin_stack_2”项目。
==>我正在尝试将所有产品作为consumeItem出售
我在应用程序开始时加载了以下函数:
AndroidIAB.androidIAB.loadPlayerInventory();
我做错了什么?
答案 0 :(得分:0)
AndroidIAB.androidIAB.loadPlayerInventory
是异步调用,这意味着您必须等待它完成。完整代码应该与此类似:
// 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();
答案 1 :(得分:0)
为了使用consumeItem,用户应该首先购买该项目,而不仅仅是可以使用consumeItem