Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"queryinventorycomplete" does not return the available products #10

Open
deckameron opened this issue Aug 30, 2015 · 1 comment
Open

Comments

@deckameron
Copy link

No matter the params of queryInventory(), it always return the same json, with no products at all. I have already bought the product but I can't restore my purchase because of it.
It have been ten days since I created the products and I don't know what else to try.

Quering all the products

InAppBilling.queryInventory({
    queryDetails: true
});

returns:

"inventory" : {
    "bubbleParent":true,
    "apiName":"Ti.Proxy"
}

Quering with product name

InAppBilling.queryInventory({
    queryDetails: true,
    moreItems: ['product']
});

also returns:

"inventory" : {
    "bubbleParent":true,
    "apiName":"Ti.Proxy"
}
@natefollmer
Copy link

Here's how I did it. I basically loop through the database and get the status for each item that's in my app:

var restore = function(arg)
{
   InAppBilling.queryInventory();
   InAppBilling.addEventListener('queryinventorycomplete', function (e)
   {
        var inventory = e.inventory;
        var purchase;
        var rows = db.execute('SELECT * FROM tablename');
        var dataArray = [];
        while (rows.isValidRow())
        {
           dataArray.push(rows.fieldByName('store_id'));
           rows.next();    
        };

        for (var i = 0; i <= dataArray.length; i++)
        {
             if (inventory.hasPurchase(dataArray[i])) 
             {
                purchase = inventory.getPurchase(dataArray[i]);
                    if (purchase.purchaseState == 0)
                    {
                       //Do your database updating here if you store your items in a DB. Example:
                       db.execute('UPDATE tablename SET owned="1" WHERE store_id="'+purchase.productId+'"');
                    }
             }
        }
   });
};

If you need more details, here's a link to my post going through this: http://smallmouthmediagroup.com/restoring-purchases-in-app-billing-module-appcelerator-android/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants