Follow this tutorial to set up RevenueCat for in-app purchases
/providers/RevenueCatProvider.tsx
and it is initialized at /app/(tabs)/_layout.tsx
like this:RevenueCatProvider
that will do this for us.
We also want to be able to purchase items and restore purchases, so we have these methods as well to the provider as well.
To make sure all of these functions are available to our React app, we create a RevenueCatContext
and export it as a useRevenueCat
hook to be used in our app.
At this point you also need your RevenueCat API keys, which you can find in your RevenueCat project under API Keys. You will need to add them to the .env
file.
RevenueCatProvider
:
PRO_MONTHLY
and PRO_ANNUAL
set up. You can add more entitlements in RevenueCat and then add them to the updateCustomerInformation
function.
Also note that we have 2 subscription types monthly
and annual
in the UserState
object.
Paywall
component:
useRevenueCat
hook like this:
useRevenueCat
hook to access the user subscription state in your app.