In App Purchases
Setup
IOS setup
Setup Expo Dev Client
🚨🚨 Important Step 🚨🚨
See instructions in Expo Dev Client
In-app-purchases will not work in Expo Go
Enable in-app-purchases in config
In
config.ts
, setrequireSubscription: true
This will automatically popup the paywall the first time the user opens the app
Fix RevenueCatProvider.tsx
Comment out this line
export const RevenueCatProvider = MockRevenueCatProvider
Uncomment the entire
RevenueCatProvider
component below that
Setting up an in-app-purchase in App Store / Play Store
Setup the product in App Store or Play Store
Create the subscription or in-app-purchase in App Store Connect
For subscriptions, see instructions here here
For in-app-purchases, the instructions are similar to the link above, just click the "in-app-putchase" tab instead
Setting up RevenueCat
Import the product into RevenueCat
See the section titled "RevenueCat Configuration" here
Create an entitlement in RevenueCat for your product
See the section titled "Entitlements" here
Attach your product to the entitlement
Create an offering in RevenueCat for your entitlement
See the section "Offerings" here
Add a package to the offering
Add your product to the package
RevenueCat API keys in code
Fetch your API keys from RevenueCat
It can be found under App > Project Settings > API Keys
See detailed instructions here
Add the API keys under
config.ts
under the revenueCat field
Setup RevenueCatProvider
in
RevenueCatProvider.tsx
Set the variable PACKAGE_ID to the package id you setup. This can be found under the offering tab in RevenueCat (ex.
$rc_lifetime
)Set the variable ENTITLEMENT_ID to the entitlement id you setup. This can be found under the entitlement tab in RevenueCat
Now, you can launch the paywall
Debugging
Make sure you're debugging using the EAS prebuild (see above). This will not work in the Expo mobile client
To reset the purchases, you need to reset it in BOTH App Store Connect and RevenueCat
Resetting in App Store Connect
On device
Go to settings > app store > sandbox account > manage > reset purchase history
In App Store Connect
Go to app store connect > users & access > sandbox > test accounts > edit > clear purchase history
Resetting in RevenueCat
Go to recent transactions and find your transaction
Click the transaction, scroll to the bottom, press delete customer
Usage
Require a purchase to access part of the app
Use the following hook to access app state
const { hasEntitlement, isLoading, purchaseEntitlement } = useRevenueCatContext()
To check if the user has the entitlement, use
if (!hasEntitlement) { return }
To automatically show the paywall screen if the user has not purchased the subscription
if (!requireEntitlement()) { return }
Last updated