$ npm install react-native-purchases --save
$ react-native link react-native-purchases
- In Xcode, in project manager, select your app target.
- Open the
Build Phases
tabe - Add a new
Copy Files Phase
, name itCopy Frameworks
- Set destination to
Frameworks
- Add
Purchases.framework
to the phase
- In XCode, in the project navigator, right click
Libraries
➜Add Files to [your project's name]
- Go to
node_modules
➜react-native-purchases
and addRNPurchases.xcodeproj
- In XCode, in the project navigator, select your project. Add
libRNPurchases.a
to your project'sBuild Phases
➜Link Binary With Libraries
- Run your project (
Cmd+R
)<
- Open up
android/app/src/main/java/[...]/MainActivity.java
- Add
import com.reactlibrary.RNPurchasesPackage;
to the imports at the top of the file - Add
new RNPurchasesPackage()
to the list returned by thegetPackages()
method
- Append the following lines to
android/settings.gradle
:include ':react-native-purchases' project(':react-native-purchases').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-purchases/android')
- Insert the following lines inside the dependencies block in
android/app/build.gradle
:compile project(':react-native-purchases')
import Purchases from 'react-native-purchases';
Purchases.setup("revenuecat_api_key", "app_user_id", (productIdentifier, purchaserInfo, error) => {
if (error) {
this.setState({error: error.message});
return;
}
this.setState({purchaserInfo})
});
Purchases.getProducts(["onemonth_freetrial"]).then((products) => {
this.setState({products})
Purchases.makePurchase("onemonth_freetrial");
});
Take a look at the example app in the example
folder.
Support for entitlements is coming soon.