libgdx / gdx-pay

A libGDX cross-platform API for InApp purchasing.
Apache License 2.0
225 stars 82 forks source link

Query inventory without internet connection #49

Closed aberkowski closed 9 years ago

aberkowski commented 9 years ago

It's not possible to offline query inventory (without sku details). querySkuDetails variable (line 249 in file gdx-pay/gdx-pay-android-openiab/src/com/badlogic/gdx/pay/android/openiab/PurchaseManagerAndroidOpenIAB.java ) is always set up to true. According to this comment http://stackoverflow.com/questions/14231859/how-to-best-save-inapp-purchase-status-locally#comment41999027_15569448 it could be fixed by changing querySkuDetails to false. I know that this variable cannot always be false, but maybe it could be parametrized earlier.

alex-dorokhov commented 9 years ago

Oh. I have set querySkuDetails in one of the latest pull requests to true, because otherwise we did have any prices. But your case is also important. I guess we should make it with two requests, you are right. The first one with "false", then call observer methods, then if the first call was successful, call queryInventory with "true" value.

You can make a pull request with the fix ;) 3 авг. 2015 г. 19:19 пользователь "Berobasket" notifications@github.com написал:

It's not possible to offline query inventory (without sku details). querySkuDetails variable is always set up to true. According to this comment http://stackoverflow.com/questions/14231859/how-to-best-save-inapp-purchase-status-locally#comment41999027_15569448 it could be fixed by changing querySkuDetails to false. I know that this variable cannot always be false, but maybe it could be parametrized earlier.

— Reply to this email directly or view it on GitHub https://github.com/libgdx/gdx-pay/issues/49.

aberkowski commented 9 years ago

What do you think about this idea: put querySkuDetails variable into PurchaseManagerConfig and user will decide what he want. User could query inventory without prices (querySkuDetails variable set to false) for the first time and then he could manualy query once again (with changing querySkuDetails in PurchaseManagerConfig to true). I don't need more detailed information about product and I don't know if querying list of products two times (always without user need) will be goog idea.

alex-dorokhov commented 9 years ago

I'm holidays currently, it's hard to take a look, sorry. But I think in this case we will break the basic idea of config: setup once. So it will make the API not so clear for the user. I would better go for something like PurchaseConfig.autoFetchInfo variable. It is better to set it to true by default, because it could be not clear for the user, why there is PurchaseSystem.getInformation method, which is always return null. Additionally we could have a method PurchaseSystem.fetchInformation() (or with other name), which fetches info for all skus. What does @noblemaster think? 4 авг. 2015 г. 7:51 пользователь "Berobasket" notifications@github.com написал:

What do you think about this idea: put querySkuDetails variable into PurchaseManagerConfig and user will decide what he want. User could query inventory without prices (querySkuDetails variable set to false) for the first time and then he could manualy query once again (with changing querySkuDetails in PurchaseManagerConfig to true). I don't need more detailed information about product and I don't know if querying list of products two times (always without user need) will be goog idea.

— Reply to this email directly or view it on GitHub https://github.com/libgdx/gdx-pay/issues/49#issuecomment-127499806.

noblemaster commented 9 years ago

I agree with alex-dorokhov to keep it simple.

A) As suggested by alex-dorokhov, we could add a "autoFetchInformation" option to PurchaseManagerConfig. In that sense we would fetch all the information during install for people that prefer that. I would not add a fetchInformation() method though. Having it in install(...) seems the more straightforward solution!?

B) Depending on the platform, it might be a lot of information to fetch? It's not just Android, but also includes iOS, Desktop markets, you name it. As far as I know no images are currently fetched. But some stores might add that in the future. In order to reduce memory consumption we could modify the getInformation(identifier) method and instead use a callback such as: void getInformation(Callback<Information> information, String identifier). In that sense we deprecate the current getInformation(identifier) method and instruct everyone to use the new method with callback.

Comments? Other ideas/suggestions?

aberkowski commented 9 years ago

You're right. @noblemaster could you add this in the near future? For me more important is to first fetch inventory with querySkuDetails set to false (method getInformation() could be changed later).

alex-dorokhov commented 9 years ago

@noblemaster sounds good to me. I also had in mind the idea from point B. 4 авг. 2015 г. 9:10 пользователь "Christoph Aschwanden" < notifications@github.com> написал:

I agree with alex-dorokhov to keep it simple.

A) As suggested by alex-dorokhov, we could add a "autoFetchInformation" option to PurchaseManagerConfig. In that sense we would fetch all the information during install for people that prefer that. I would not add a fetchInformation() method though. Having it in install(...) seems the more straightforward solution!?

B) Depending on the platform, it might be a lot of information to fetch? It's not just Android, but also includes iOS, Desktop markets, you name it. As far as I know no images are currently fetched. But some stores might add that in the future. In order to reduce memory consumption we could modify the getInformation(identifier) method and instead use a callback such as: void getInformation(Callback information, String identifier). In that sense we deprecate the current getInformation(identifier) method and instruct everyone to use the new method with callback.

Comments? Other ideas/suggestions?

— Reply to this email directly or view it on GitHub https://github.com/libgdx/gdx-pay/issues/49#issuecomment-127515050.

noblemaster commented 9 years ago

OK, going with point B (using a callback for getInformation(...)) and not querying the SKU-details during install(...) makes the most sense.

Also, I don't use the getInformation. I would definitely be in favor of not querying the SKU-details during install as well! Would someone mind submitting a pull request? Sorry, I am little bit busy at the moment to implement this myself.

alex-dorokhov commented 9 years ago

Sorry, I have thought more and tried to go with option B, but it requires to many changes and also complexifies the usage of the library. It was much easier to go with option A. I would suggest to do not overcomplicated getInformation method without real need.

alex-dorokhov commented 9 years ago

Oops, will do the pull request without the conflict

noblemaster commented 9 years ago

Fair enough! Merged :-D