I just wanted to report an incorrect code snippet in the iOS subscription offers documentation. I spent several hours trying to debug why it wasn’t working for me in React Native, so it would be helpful if this could be fixed so it can benefit others in the future.
Here is the documentation page in question
The error is only present in the React Native code snippet provided:
I uncovered this issue when I checked the other tabs of the code-snippet and searched inside the /src/purchases.ts file of the react-native-purchases package, and found that there is no method called “getPaymentDiscount”. This line is supposed to be:
const paymentDiscount = await Purchases.getPromotionalOffer(product, product.discounts);
Note: getPaymentDiscount is replaced by getPromotionalOffer.
I have tested this code and after providing the product and discount from the package, I was successfully able to call:
If someone from the RevenueCat team sees this, I would greatly appreciate if you could update the documentation for the React Native SDK in order to correct this error :)
Hope this saves someone else a headache!
Thanks for pointing this out, and sorry for all the time wasted!
We are currently building a system to automatically update and test all code snippets in our docs so that this kind of thing doesn’t happen again.