Skip to main content
Solved

Please fix incorrect React Native examples in Offering documentation

  • March 29, 2023
  • 1 reply
  • 73 views

Forum|alt.badge.img+3

I’m trying to use an offering with multiple packages (using custom identifiers), and the documentation is incorrect when it says you can access an offering and a package via its identifier in this section:

https://www.revenuecat.com/docs/displaying-products#displaying-packages

 

It says to use this code:

offerings.all("experiment_group").package("<package_id>")

But in the RevenueCat SDK, “all” is a property and not a method. See PurchasesOfferings interface:

https://revenuecat.github.io/react-native-purchases-docs/5.13.1/interfaces/PurchasesOfferings.html#current

 

Similarly, there is no “package” function on the PurchasesOffering interface:

https://revenuecat.github.io/react-native-purchases-docs/5.13.1/interfaces/PurchasesOffering.html

It seems like the only way to get this is to search through the availablePackages array until you find a matching identifier.

Best answer by sharif

Hey Stevie!

Keeping us on our toes with our documentation I see :) thanks a lot for the report. For what it’s worth we have a larger project going on behind the scenes to make sure our code snippets are correct and up to date. But for now I made this update:

- offerings.all("experiment_group").monthly
+ offerings.all["experiment_group"].monthly
- offerings.all("experiment_group").package("<package_id>")
+ offerings.all["experiment_group"].availablePackages.find(package => package === "<package_id>")

The parentheses were definitely a typo, all is definitely a typo as it’s an array, not a function.

I’m not sure where the package function came from though, it may have been a holdover from old versions of our SDK. But yes, you do have to search through the availablePackages for your package. I provided a way to do that using the find method of the array, but this is just a suggestion.

Please let me know if you have any other questions!

View original
Did this post help you find an answer to your question?

1 reply

sharif
RevenueCat Staff
Forum|alt.badge.img+9
  • RevenueCat Staff
  • 513 replies
  • Answer
  • March 31, 2023

Hey Stevie!

Keeping us on our toes with our documentation I see :) thanks a lot for the report. For what it’s worth we have a larger project going on behind the scenes to make sure our code snippets are correct and up to date. But for now I made this update:

- offerings.all("experiment_group").monthly
+ offerings.all["experiment_group"].monthly
- offerings.all("experiment_group").package("<package_id>")
+ offerings.all["experiment_group"].availablePackages.find(package => package === "<package_id>")

The parentheses were definitely a typo, all is definitely a typo as it’s an array, not a function.

I’m not sure where the package function came from though, it may have been a holdover from old versions of our SDK. But yes, you do have to search through the availablePackages for your package. I provided a way to do that using the find method of the array, but this is just a suggestion.

Please let me know if you have any other questions!


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings