[IAP][Android] Refreshing product details after init

I am following a simple process where I init the IAP system and upon receiving an “init” callback, I make a call to loadProducts after checking for “canLoadProducts”.

Everything works as expected on the first run-- the requested products are retrieved together with all their details and I am able to use those details to populate my “shop” UI.

The problem I am facing is that this only happens on the first run of the app on any device and subsequently, irrespective of whether the device is connected to a network or not, I continue to receive the same products and the init process goes through unhindered. So, for instance, if I revise the prices of the products on the store, my programme never returns the new prices.

Internally, everything seems to still work-- if I actually request to purchase an item, the native OS popup is shown with the live prices etc but the data returned by loadProducts NEVER changes. 

This is also true if I uninstall the app and then reinstall it on the same device-- even without an internet connection, I get a callback for my loadProducts call and the original products are retrieved. 

I have looked around on the forum and gone through the entire API but there’s nothing that looks to me like it could refresh the products table or prevent them from being fetched if the device is not online. 

I’d appreciate if someone could point me to a possible solution or indicate if there’s something that I’ve missed out-- my code is quite simple-- init the store; receive a callback for a successful init; request for products to be loaded; populate a local table for the retrieved products which are returned in the callback.

Thanks in advance.

  1. If I understood, the nutshell problem is:

After your first app run, you continue to request a products list/catalog on each subsequent run, but the details are always the same as the first time you retrieved them.

If I have this wrong, please correct me.

  1. Are you coding this all yourself or using IAP Badger?  It sounds like you’re doing this yourself. 

  2. How long did you wait after changing the prices to test this?   It may take quite some time for the stores to update the price.

Hi roaminggamer,

  1. Yes, you have correctly described the problem

  2. I am not using IAP badger

  3. I waited for long enough for the revised prices to go live (close 12 hours now)- the problem, as I had explained in the first post, is that the products don’t seem to be fetched from a server at all! Even with the network disconnected, the loadProducts function returns the same products which were fetched on the very first run.

Purchase actions etc all work just fine but the list of items is never revised. 

Will appreciate any inputs. Cheers

Which flavour of Android is this (Google Play or Amazon)?

If you’re testing on Amazon, it may be you need to update your JSON test file with prices in etc.
 

Simon

It’s Google Play. It’s the same on ios-- the products load up even when not connected to the internet.

A co-dev tried deleting some files that are cached in our app’s android folders on his device and the latest products with the current prices were fetched from the server the next time he loaded up the app so it seems that this is intended behaviour for some reason and that the IAP details are cached by the plugin in some way or form. 

The prices are still refreshed if we do not delete the cached files but that can take up to 72 hours sometimes whereas google’s servers almost never need more than 3-4 hours for the changes to the products to reflect 

Could you let us know:

* When and where are you calling loadProducts?

* How are you storing the information passed to loadProducts (it sounds like it may be in some sort of file?)

It would also be helpful if you’d be willing to share the code for your loadProducts listener, so we could see the detail for ourselves.

As Roaming Gamer mentioned, there can be a delay in updating prices on both Google Play and iTunes Connect, though 12 hours seems excessive.

If it helps, I don’t think this is an IAP library issue.  I wrote the IAP Badger plug-in - so I have some experience of this sort of thing - and I haven’t come across this problem before.

In particular, I don’t think this is an intended behaviour of any of the IAP libraries - especially as you’re getting this result across both iOS and Google Play.

Thanks for your inputs and good work on your plugin!

Tbh, the only “problem” that I have in my IAP implementation at this point is that it takes between 24-72 hours for a change in prices to reflect, but they DO eventually get revised, so maybe it is not my programme or the library at all!

It is still annoying though so  I’ll describe my implementation below, in case you can spot something:

These are the steps I follow, in order (android):

  • Call the init function for the store

  • In the transactionListener, I watch for an “init” event and call the loadProducts upon init

  • The information on the products is stored locally in a table. This happens independently in the background and not necessarily when a “shop”/“store” GUI is called. 

  • When the relevant GUI/ menu is called, I check the said table to see if products were loaded and then populate a list of the products. 

The product listener, itself, is VERY simple-- it just iterates over event.products table which was returned and stores those locally. 

Not to sound arrogant or anything, but I’ve gone over my code and the APIs a dozen times now so I know that I’m not really doing anything wrong! The only difference for my ios implementation is that after initing the store, I poll endlessly (enterFrame) to see if the store was active (since there isn’t an init event in ios) and once the store is ready, I stop the polling and load the products. 

Everything works on both OS but I get successful callbacks for init, loadproducts etc even when I am offline which is obviously something that’s a part of the library. Could you maybe check and see if you get a callback for loadProducts even when not connected to a network?

Your implementation sounds spot on to me.

When I get a moment, I’ll check on a device to see what happens - my guess will be that Google Play caches information about IAP pricing for downloaded apps when the user is offline (though I’d be surprised if you can make a purchase when you were offline…)

An easy test would be to run your app (so loadProducts gets called), clear the cache for Google Play (rather than for your app - do this through the device’s settings menu) and then see if the correct prices are provided afterwards.

If this remedies the problem, then it looks like a Google Play cacheing problem.

On my games if I load offline I get no purchases available so there is definitely something weird going on.

I’ll try clearing the GPlay cache and revert. I should also clarify that attempting to purchase any of the products when offline doesn’t work so that’s not a problem. 

Although if this was a caching issue with GPlay, the ios implementation would not have had the same behaviour but on ios too, if I allow the products to load once, their details seem to persist even after I reinstall the app.

Either way, It’s not such a bother tbh since the core functionality of IAPs works just fine-- if you can please post back after checking your loadProducts behaviour without internet, it would certainly clear things up. 

cheers!

Does that mean that the products won’t load at all when you’re offline or that you’re just not able to buy them? I can obviously not purchase anything or restore previous purchases when I’m offline-- just that the products are still fetched from the store even when there’s no connection. 

loadProducts() returns empty - i.e. no IAP data

I see. For me it returns the list of products that it last fetched when the system was online. Quite bizarre! 

Tbf, there is nothing that you and I could’ve done differently in calling loadProducts so I’m struggling to see why products are being cached for me (on both Android and IOS) and not for you. 

Anyway, I’ll let it be I guess- it still does its job and doesn’t greatly affect usability 

  1. If I understood, the nutshell problem is:

After your first app run, you continue to request a products list/catalog on each subsequent run, but the details are always the same as the first time you retrieved them.

If I have this wrong, please correct me.

  1. Are you coding this all yourself or using IAP Badger?  It sounds like you’re doing this yourself. 

  2. How long did you wait after changing the prices to test this?   It may take quite some time for the stores to update the price.

Hi roaminggamer,

  1. Yes, you have correctly described the problem

  2. I am not using IAP badger

  3. I waited for long enough for the revised prices to go live (close 12 hours now)- the problem, as I had explained in the first post, is that the products don’t seem to be fetched from a server at all! Even with the network disconnected, the loadProducts function returns the same products which were fetched on the very first run.

Purchase actions etc all work just fine but the list of items is never revised. 

Will appreciate any inputs. Cheers

Which flavour of Android is this (Google Play or Amazon)?

If you’re testing on Amazon, it may be you need to update your JSON test file with prices in etc.
 

Simon

It’s Google Play. It’s the same on ios-- the products load up even when not connected to the internet.

A co-dev tried deleting some files that are cached in our app’s android folders on his device and the latest products with the current prices were fetched from the server the next time he loaded up the app so it seems that this is intended behaviour for some reason and that the IAP details are cached by the plugin in some way or form. 

The prices are still refreshed if we do not delete the cached files but that can take up to 72 hours sometimes whereas google’s servers almost never need more than 3-4 hours for the changes to the products to reflect 

Could you let us know:

* When and where are you calling loadProducts?

* How are you storing the information passed to loadProducts (it sounds like it may be in some sort of file?)

It would also be helpful if you’d be willing to share the code for your loadProducts listener, so we could see the detail for ourselves.

As Roaming Gamer mentioned, there can be a delay in updating prices on both Google Play and iTunes Connect, though 12 hours seems excessive.

If it helps, I don’t think this is an IAP library issue.  I wrote the IAP Badger plug-in - so I have some experience of this sort of thing - and I haven’t come across this problem before.

In particular, I don’t think this is an intended behaviour of any of the IAP libraries - especially as you’re getting this result across both iOS and Google Play.

Thanks for your inputs and good work on your plugin!

Tbh, the only “problem” that I have in my IAP implementation at this point is that it takes between 24-72 hours for a change in prices to reflect, but they DO eventually get revised, so maybe it is not my programme or the library at all!

It is still annoying though so  I’ll describe my implementation below, in case you can spot something:

These are the steps I follow, in order (android):

  • Call the init function for the store

  • In the transactionListener, I watch for an “init” event and call the loadProducts upon init

  • The information on the products is stored locally in a table. This happens independently in the background and not necessarily when a “shop”/“store” GUI is called. 

  • When the relevant GUI/ menu is called, I check the said table to see if products were loaded and then populate a list of the products. 

The product listener, itself, is VERY simple-- it just iterates over event.products table which was returned and stores those locally. 

Not to sound arrogant or anything, but I’ve gone over my code and the APIs a dozen times now so I know that I’m not really doing anything wrong! The only difference for my ios implementation is that after initing the store, I poll endlessly (enterFrame) to see if the store was active (since there isn’t an init event in ios) and once the store is ready, I stop the polling and load the products. 

Everything works on both OS but I get successful callbacks for init, loadproducts etc even when I am offline which is obviously something that’s a part of the library. Could you maybe check and see if you get a callback for loadProducts even when not connected to a network?

Your implementation sounds spot on to me.

When I get a moment, I’ll check on a device to see what happens - my guess will be that Google Play caches information about IAP pricing for downloaded apps when the user is offline (though I’d be surprised if you can make a purchase when you were offline…)

An easy test would be to run your app (so loadProducts gets called), clear the cache for Google Play (rather than for your app - do this through the device’s settings menu) and then see if the correct prices are provided afterwards.

If this remedies the problem, then it looks like a Google Play cacheing problem.