Magic Weather is a sample app demonstrating the proper methods for using RevenueCat's Purchases SDK. This sample uses only native platform components - no third-party SDK's other than the Purchases SDK.
Sign up for a free RevenueCat account here.
This sample uses:
- React Native 0.63.4
- react-native-purchases: ^4.0.0
See minimum react-native version requirements for RevenueCat's Purchases SDK here.
Feature | Sample Project Location |
---|---|
🕹 Configuring the Purchases SDK | App.js |
💰 Building a basic paywall | src/screens/PaywallScreen/index.js |
🔐 Checking subscription status | src/screens/WeatherScreen/index.js |
🤑 Restoring transactions | src/components/RestorePurchasesButton/index.js |
👥 Identifying the user | src/components/LoginForm/index.js |
🚪 Logging out the user | src/components/LogoutButton/index.js |
- Be sure to have an an Apple Developer Account or Google Play Console Account.
- Be sure to set up at least one subscription on the App Store or Play Store and link it to RevenueCat:
- Add the product (e.g.
rc_3999_1y
) to RevenueCat's dashboard. It should match the product ID on the App/Play Store. - Attach the product to an entitlement, e.g.
premium
. - Attach the product to a package (e.g.
Annual
) inside an offering (e.g.sale
ordefault
).
- Add the product (e.g.
- Get your API key from your RevenueCat project.
-
Download or clone this repository
git clone https://github.com/RevenueCat/react-native-purchases.git
-
Ensure you have node package manager (npm) installed on your machine.
-
Navigate into the
MagicWeather
directory and install the dependencies using npmcd react-native-purchases/examples/MagicWeather npm install
-
Navigate into the
ios
directory and install the pod file.cd ios pod install
-
Open the
Xcode project
file (ios/MagicWeatherReactNative.xcodeproj) and match thebundle ID
to your App Store package in App Store Connect and RevenueCat. -
Open the
build.gradle
file (android/app/build.gradle#L134) and matchapplicationId
to your Google Play package in Google Play Console and RevenueCat. -
Open
Constants/index.js
(src/constants/index.js):- Replace the value for
API_KEY
with the API key from your RevenueCat project. - Replace the value for
entitlementID
with the entitlement ID of your product in RevenueCat's dashboard. - Comment out the error directives.
- Replace the value for
-
Run the app on a simulator or physical device.
npm run ios
or
npm run android
- On the home page, select Change the Weather.
- On the prompted payment sheet, select the product listed.
- On the next modal, select Subscribe.
- On the next modal, sign in with your Sandbox User ID.
- On the next modal, select Ok.
- Return to the home page and select Change the Weather to see the weather change!
For more technical resources, check out our documentation.
Looking for RevenueCat Support? Visit our Help Center.
This React Native sample was built by Vadim Savin from notjust.dev