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 SDKs other than the Purchases SDK.
Sign up for a free RevenueCat account here.
This sample uses:
- Android Studio
- Android 8.0+ (API level 26+)
- Kotlin 1.6.21
See minimum platform version requirements for RevenueCat's Purchases SDK here.
Feature | Sample Project Location |
---|---|
🕹 Configuring the Purchases SDK | MainApplication.kt |
💰 Building a basic paywall | paywall/PaywallFragment.kt |
🔐 Checking subscription status | weather/WeatherFragment.kt |
🤑 Restoring transactions | user/UserFragment.kt |
👥 Identifying the user | user/UserFragment.kt |
🚪 Logging out the user | user/UserFragment.kt |
- Be sure to have a Google Play Console Account.
- Be sure to set up at least one subscription on the Play Store following our guide 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 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/purchases-android.git
-
Open the MagicWeather project in Android Studio
-
In
build.gradle
, matchapplicationId
to your Google Play package in Google Play Console and RevenueCat. -
In the
Constants.kt
file:- Replace the value for
GOOGLE_API_KEY
with the API key from your RevenueCat project. - Replace the value for
AMAZON_API_KEY
with the API key from your RevenueCat project (if applicable). - Replace the value for
entitlementID
with the entitlement ID of your product in RevenueCat's dashboard.
- Replace the value for
-
Run the app on a simulator or physical device.
- 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 community.