Skip to main content

I have created a product in google play console, and I also created a revenuecat product with the same id, but the the following line of code returns an empty array.


// Fetching all products by passing an array of their product_id
const products = await Purchases.getProducts(['product_id']);

// Printing the list of products available.
console.log(products);


// Example response:
[]

Project info:

  • Expo SDK version: 45
  • React native: 0.68.2
  • react-native-purchases: 4.6.1
  • Device tested: android

Hey @kunga_tashi 

Have you had a chance to take a look at this community post?

Oftentimes when developers are having issues fetching their products, it is due to a step missing from the community post above. 


I am having the same problem. The lack of insights into the problem is driving me crazy :-)

 

Can’t RC log relevent info whenever we encounter problems like this!?

 

E.g. if I pass id’s that do not exist please state so and list the available ones.

 

I guess the api’s towards App Store and Play Store has this capability!?

 

I have tried everything (I think) now but the result is always an empty list.


Hi @kunga_tashi,

I have the exact same issue on the same tech stack. Have you been able to solve this issue?

Would be great if would share some insights :)

Thank you

Roman


Hey @Roman Zinnatov ,

I found an alternative solution to this problem which I think might be helpful. 
So instead of using the Purchases.getProducts() method, try configuring offerings and packages and then use the Purchases.getOfferings() method.

If you go to the revenuecat dashboard, just above the products section, you will see an offerings section, create one offering which would act like a container for all your packages. Once you have created the offering, you will see it reflect on the right side. You can click on that and then proceed to create packages. You can consider each package as equivalent to your product, what you have to do is attach a product to a specific package.
 

This link contains how to fetch the offerings once setup - Display in app purchases 
This method worked well for me, and the offerings were getting fetched. Do let me know if its working for you or not. 

Kunga


@kunga_tashi 

Kunga,

Thank you so much for such a quick reply!

Guys from RevenueCat support pointed out to the doc of .getProducts method. It turned out that it has second input parameter, which is optional and has default value as SUBS.

I didn’t specify it, so once I passed INAPP as the second param to .getProducts, it started to return my products instead of an empty array.

Hope it would help someone.
Roman


For me the `getProducts` also returned an empty array but the cause was actually that it doesn’t seem to take product ids but product group ids. So actually the docs are wrong there. You can find those when clicking on a product and then its product group.


For me the `getProducts` also returned an empty array but the cause was actually that it doesn’t seem to take product ids but product group ids. So actually the docs are wrong there. You can find those when clicking on a product and then its product group.

...and if that doesn’t work for you, try putting all products into an offering and list the offerings via `getOfferings()`, in the response you can see the “product ids”.


@kunga_tashi

Kunga,

Thank you so much for such a quick reply!

Guys from RevenueCat support pointed out to the doc of .getProducts method. It turned out that it has second input parameter, which is optional and has default value as SUBS.

I didn’t specify it, so once I passed INAPP as the second param to .getProducts, it started to return my products instead of an empty array.

Hope it would help someone.
Roman

Mate, thank you so much for this. I’ve spent an entire month on this one issue. What a feeling to get it sorted. I was just one word away the whole time!


For me the `getProducts` also returned an empty array but the cause was actually that it doesn’t seem to take product ids but product group ids. So actually the docs are wrong there. You can find those when clicking on a product and then its product group.

...and if that doesn’t work for you, try putting all products into an offering and list the offerings via `getOfferings()`, in the response you can see the “product ids”.

This worked for me. How bizarre that getProducts() doesn’t return the same products contained in the offering, when requested by a specific ID and the correct product type/category.


For me the `getProducts` also returned an empty array but the cause was actually that it doesn’t seem to take product ids but product group ids. So actually the docs are wrong there. You can find those when clicking on a product and then its product group.

...and if that doesn’t work for you, try putting all products into an offering and list the offerings via `getOfferings()`, in the response you can see the “product ids”.

THIS! I’ve been struggling for an entire week on this. Thank you.

So instead for giving o ‘supporter:one-month’, ‘premium:one-month’, ‘premium:three-months’ ], it was just t ‘supporter’, ‘premium’ ] and now it works perfectly


@kunga_tashi

Kunga,

Thank you so much for such a quick reply!

Guys from RevenueCat support pointed out to the doc of .getProducts method. It turned out that it has second input parameter, which is optional and has default value as SUBS.

I didn’t specify it, so once I passed INAPP as the second param to .getProducts, it started to return my products instead of an empty array.

Hope it would help someone.
Roman

Can you share an exemple please ? 


For me the `getProducts` also returned an empty array but the cause was actually that it doesn’t seem to take product ids but product group ids. So actually the docs are wrong there. You can find those when clicking on a product and then its product group.

Jesus Christ man. Don’t know how you figured this out, but cheers.


Reply