Skip to content

Latest commit

 

History

History

MagicWeather

Magic Weather Android - RevenueCat Sample

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.

Requirements

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.

Features

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

Setup & Run

Prerequisites

  • 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 or default).
  • Get your API key from your RevenueCat project.

Steps to Run

  1. Download or clone this repository

    git clone https://github.com/RevenueCat/purchases-android.git

  2. Open the MagicWeather project in Android Studio

    Android Studio open file navigation
  3. In build.gradle, match applicationId to your Google Play package in Google Play Console and RevenueCat.

    Build Gradle with applicationId
  4. 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.
    Constants.kt file
  5. Run the app on a simulator or physical device.

    Run Android Studio project Run Android Studio project

Example Flow: Purchasing a Subscription

  1. On the home page, select Change the Weather.
  2. On the prompted payment sheet, select the product listed.
  3. On the next modal, select Subscribe.
  4. On the next modal, sign in with your Sandbox User ID.
  5. On the next modal, select Ok.
  6. Return to the home page and select Change the Weather to see the weather change!

Purchase Flow Demo (iOS version)

Support

For more technical resources, check out our documentation.

Looking for RevenueCat Support? Visit our community.