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:
- Xcode 15.3
- iOS 15
- Swift 5
See minimum platform version requirements for RevenueCat's Purchases SDK here.
Feature | Sample Project Location |
---|---|
🕹 Configuring the Purchases SDK | Lifecycle/AppDelegate.swift |
💰 Building a basic paywall | Controllers/UserViewController.swift |
💰 Building a targeted paywall | Controllers/WeatherViewController.swift |
🔐 Checking subscription status | Controllers/WeatherViewController.swift |
🤑 Restoring transactions | Controllers/UserViewController.swift |
👥 Identifying the user | Controllers/UserViewController.swift |
🚪 Logging out the user | Controllers/UserViewController.swift |
- Be sure to have an Apple Developer Account.
- You must join the Apple Developer Program to create In-App Purchases.
- You must sign the Paid Applications Agreement and complete your bank/tax information to test In-App Purchases.
- Be sure to set up a Sandbox Tester Account for testing purposes.
- Add your App-Specific Shared Secret to RevenueCat. If you don't have a RevenueCat account yet, sign up for free here.
- Be sure to set up at least one subscription on the App 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 App 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.
- Create a Paywall for your default offering.
-
Download or clone this repository
-
Navigate to the
Examples
directory and open the fileMagicWeather.xcodeproj
in Xcode. -
On the General tab of the project editor, match the bundle ID to your bundle ID in App Store Connect and RevenueCat.
-
On the Signing & Capabilities tab of the project editor, select the correct development team from the Team dropdown.
-
In the
Constants.swift
file:- Replace the value for
apiKey
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
-
Build the app and run it on your 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 Apple 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.