Solved

Please fix incorrect React Native examples in Offering documentation

  • 29 March 2023
  • 1 reply
  • 64 views

Badge +1

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.

icon

Best answer by sharif 1 April 2023, 01:05

View original

1 reply

Userlevel 5
Badge +9

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