11

I found the following code from here to get products list from google play store

ArrayList skuList = new ArrayList();
skuList.add("premiumUpgrade");
skuList.add("gas");
Bundle querySkus = new Bundle();
querySkus.putStringArrayList(“ITEM_ID_LIST”, skuList);

is there a way to get dynamic products list? here its hard coded.what happens when i add new products after app launch?

user1688181
  • 496
  • 1
  • 10
  • 27

6 Answers6

33

This is not currently possible using Google API.

Create a JSON file that contains current SKUs and place it on some server.

In your app, first load this file from server URL and then use this list of SKUs to retrieve product details via Google API.

To Google: Provide function for this, SHAME ON YOU!

Dusan
  • 5,000
  • 6
  • 41
  • 58
  • 1
    Not available yet, till now Oct 16 '15. Shame on you, google, and apple too . lol – Nhat Dinh Oct 16 '15 at 06:21
  • @Dinh, please give me the link to the reference, cannot find it. – Dusan Oct 16 '15 at 08:06
  • 1
    https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/StoreKitGuide/Chapters/ShowUI.html#//apple_ref/doc/uid/TP40008267-CH3-SW6 There’s no runtime mechanism to fetch a list of all products configured in iTunes Connect for a particular app. You’re responsible for managing your app’s list of products and providing that information to your app. If you need to manage a large number of products, consider using the bulk XML upload/download feature in iTunes Connect. – Nhat Dinh Oct 19 '15 at 06:00
6

If you don't want to implement the logic to acquire the product list from your own server, another option would be to use pre-defined "dummy" product ids, like product id slots:

private static final String[] PRODUCTIDS = {"product1", "product2", "product3", etc. };

The getSkuDetails function will simply return null for non-existing product ids. So if you don't expect your product list to vary too often or too much, then you could just define a small number of product ids in your app, and skip null values returned by getSkuDetails.

If you want to add a new product, just use the id defined by the next unused slot in the developer console, and your app will list it without updating the app.

Deleting a product can be tricky, because inactive and deleted product ids will still be returned, so you could mark a product deleted using its description field - use a pre-defined constant, like "NOT AVAILABLE" and check for its presence in your app. If a product description equals to this constant, simply skip it and don't list it.

I know, I know. It's a dirty hack. But it works.

Levente Dobson
  • 773
  • 8
  • 10
  • If you are using the helper classes from the example Google project then you can query the products by calling `IabHelper.queryInventoryAsync(final boolean querySkuDetails, final List moreSkus, final QueryInventoryFinishedListener listener)` (or the synchronous version if you prefer), just specify the list of SKUs as the mystic `moreSkus` parameter. You need to get the previously purchased products anyway, so it is hard to avoid this call. Still ugly to put it mildly. – racs Jan 27 '16 at 22:46
2

It is not possible for a reason. If you were able to fetch the updated inapp product list how would you be able to serve those new products without changing the app code? If you change the product list then you have to release an update for the app that deals with the new products.

The only reason to fetch new products without changing the app code would be to change prices for the products themselves but that would mean going against the Google terms & conditions

Gianluca Ghettini
  • 11,129
  • 19
  • 93
  • 159
  • Handling should be left to developers. Many developers handle in-app functionality serverside. And BTW it's not Google's concern. – Kishan Vaishnav Apr 27 '18 at 09:29
1

This is now possible using the Inappproducts: list API:

List all the in-app products for an Android app, both subscriptions and managed in-app products.

Also, read about Authorization which is needed for making use of above API.

Malwinder Singh
  • 6,644
  • 14
  • 65
  • 103
0

One way you can do this is to create a copy of all your product IDs in a database (like Firebase DB), query these IDs in your app and add them to a String list. Then finally pass this list to the SkuDetailsParams setSkusList() method:

SkuDetailsParams params = SkuDetailsParams.newBuilder()
                        .setType(INAPP)
                        .setSkusList(skuList) //pass the list there
                        .build();
sammy
  • 185
  • 2
  • 13
0

I guess, the simplest way is to use Firebase Remote Config, where skuList will be updated automatically once published to all devices.

Check Remote Config for implementation: https://firebase.google.com/docs/remote-config/use-cases

Ayman Al-Absi
  • 2,630
  • 24
  • 22