What is RevenueCat?
RevenueCat is an in-app subscription platform that makes it easy to build and manage IAPs on any platform. With the RevenueCat SDK, you can build and manage your app business on any platform without having to maintain purchase infrastructure. You can read more about how RevenueCat fits into your app or you can sign up free to start building.
Installation
Purchases for React Native can be installed either via npm or yarn.
npm install --save react-native-purchases
yarn add react-native-purchases
After that, you should link the library to the native projects by doing:
react-native link react-native-purchases
Additional iOS Setup
1. Installing with Cocoapods / ExpoKit
If your project already uses Cocoapods to install iOS dependencies, common in ExpoKit projects, linking the library should have added it to the podfile. If it hasn't, add the following to your project's podfile to reference the library from your node_modules folder:
pod 'RNPurchases', :path => '../node_modules/react-native-purchases', :inhibit_warnings => true, :modular_headers => false
In your iOS folder, run pod install. If you've just upgraded ExpoKit, you might need to upgrade cocoapods to the newest version: sudo gem install cocoapods.
That's it! You can skip ahead to importing the framework
2. Manually adding the framework (if you're not using Cocoapods)
If you are not using Cocoapods to manage dependencies, Purchases.framework also needs to be added to your iOS project. The npm install will download the correct framework version and the link command will add libRNPurchases.a
to the Linked Frameworks and Libraries of your app target in the iOS project.
If you choose to install the framework via CocoaPods you can skip steps 1 through 4 below.
3. Create a Framework Reference in your project
- Drag
Purchases.framework
andPurchasesHybridCommon.framework
from theRNPurchases
sub-project under the libraries section to the outer project and create a reference.
4. Add iOS Framework to Embedded Binaries
- In Xcode, in project manager, select your app target.
- Select the general tab
- Drag
Purchases.framework
andPurchasesHybridCommon.framework
from your project to the Embedded Binaries section
Add $(PROJECT_DIR)/../node_modules/react-native-purchases/ios
to Framework Search paths in build settings
3. Add Strip Frameworks Phase
The App Store, in it's infinite wisdom, still rejects fat frameworks, so we need to strip our framework before it is deployed. To do this, add the following script phase to your build.
- In Xcode, in project manager, select your app target.
- Open the
Build Phases
tab - Add a new
Run Script
, name itStrip Frameworks
- Add the following command
"${PROJECT_DIR}/../node_modules/react-native-purchases/ios/strip-frameworks.sh"
(quotes included)
5. Link static library
The react-native link
command should have added the libRNPurchases.a
library to the Linked Frameworks and Libraries section of your app target. If it hasn't add it like this:
Import Purchases
You should now be able to import Purchases
import Purchases from 'react-native-purchases';
Include BILLING permission for Android projects
Don't forget to include the
BILLING
permission in your AndroidManifest.xml file
<uses-permission android:name="com.android.vending.BILLING" />
Enable In-App Purchase for your iOS project
Don't forget to enable the In-App Purchase capability for your project under
Project Target -> Capabilities -> In-App Purchase


ExpoKit special instructions
ExpoKit projects of version 33 or higher can successfully use react-native-purchases. If you haven't upgraded, you can follow the instructions here to upgrade.
If you're planning on ejecting from Expo, upgrade your expo version first, THEN eject. It'll save you a whole lot of hassle.
Next Steps
- Now that you've installed the Purchases SDK in your React Native app, get started by initializing an instance of Purchases
Updated about a month ago