Solved

GetProducts type magic string and empty products array

  • 1 August 2023
  • 2 replies
  • 104 views

Badge +6

In Unity SDK there is GetProducts method with this semantics:

public void GetProducts(string[] products, GetProductsFunc callback, string type = "subs")

 

How we should know this magic strings for “type”?

 

I want to display Price in game user interface. This price can be obtained through StoreProduct. But I can’t get ANY StoreProduct, because GetProducts alwats return empty array. I wanted to change type from “subs” to anything else, but there is no another constants mentioned in docs \ code.

 

Please help me to fetch all my products and check prices for them. 

Platform: Unity3d, Android & iOS

icon

Best answer by sharif 3 August 2023, 22:46

View original

2 replies

Badge +6

Still can’t understand how this function works. For now we swith to GetOfferings because at least we understand how it works. For this we still need additional explanations \ docs. 

Userlevel 5
Badge +9

Hello,

Thanks for the honest feedback, we’ll improve our docs here.

We do have a sample app that might help see the usage of our SDK, for example here’s a “GetAllProducts” method that gets all products by using GetOfferings and GetProducts: https://github.com/RevenueCat/purchases-unity/blob/0be86203d1d7c98d80486f0124fa38e331aa3373/Subtester/Assets/Scripts/PurchasesListener.cs#L517-L549

The two values that type can be are “subs” and “inapp” as seen here: https://github.com/RevenueCat/purchases-hybrid-common/blob/0c645cf492a118035282bdb4214b61c82fb5d124/android/src/main/java/com/revenuecat/purchases/hybridcommon/common.kt#L522-L523

I don’t expect you to dig through the code to find those, I’m simply sharing them here to help out. I’ll add a ticket in our system to document them.

Reply