Skip to main content

React Native

What is RevenueCat?

RevenueCat provides a backend and a wrapper around StoreKit and Google Play Billing to make implementing in-app purchases and subscriptions easy. With our SDK, you can build and manage your app business on any platform without having to maintain IAP infrastructure. You can read more about how RevenueCat fits into your app or you can sign up free to start building.

Installation

Make sure that the deployment target for iOS is least 13.4 and Android is at least 6.0 (API 23) as defined here.

Option 1: React-Native package

Purchases for React-Native can be installed either via npm or yarn. We recommend using the latest version of React Native, or making sure that the version is at least greater than 0.64.

Option 1.1: Using auto-linking

Recent versions of React Native will automatically link the SDK, so all that's needed is to install the library.

npm install --save react-native-purchases

Option 1.2: Manual linking

npm install --save react-native-purchases

After that, you should link the library to the native projects by doing:

react-native link react-native-purchases

Option 2: Using Expo

react-native-purchases works with with any Expo project when using a development build. A development build helps you iterate as quickly as possible and provides a more flexible, reliable, and complete development environment. It also enables you to only write JavaScript/TypeScript while letting Expo tools and services take care of everything else. The Android and iOS apps are built using Expo's build service and generate development and production binaries for testing and releasing.

As of mid 2021, projects created with Expo now support in-app payments and are compatible with react-native-purchases. Running npx expo install react-native-purchases is all that needs to be done before you can start implementing RevenueCat into your app.

Note: Expo's docs state that in-app purchases will only work on real Android and iOS devices which can make debugging more difficult. You can view the RevenueCat debug logs on Android with LogCat and iOS with Console.app.

For more information, see our blog post here.

Bare workflow

If you are using bare workflow (that is, your project is created using react-native init), install expo into your project and leverage Expo CLI to use Expo tooling and services.

The bare workflow gives developers complete native control but also allows the use of Expo libraries and services. The bare workflow is similar to a project you would get from npx react-native init.

If you're planning on ejecting from Expo to use the bare workflow, upgrade your Expo version first, then eject. It'll save you a whole lot of hassle.

Get started with the bare workflow here.

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 capability for your iOS project

Don't forget to enable the In-App Purchase capability for your project under Project Target -> Capabilities -> In-App Purchase

Next Steps