Skip to content

Latest commit

 

History

History

MagicWeatherSwiftUI

Magic Weather SwiftUI - 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:

  • SwiftUI
  • Xcode 14.0
  • iOS 15.0
  • Swift 5

See minimum platform version requirements for RevenueCat's Purchases SDK here.

Features

Feature Sample Project Location
🕹 Configuring the Purchases SDK Lifecycle/MagicWeatherApp.swift
💰 Building a basic paywall Views/PaywallView.swift
🔐 Checking subscription status Views/WeatherView.swift
🤑 Restoring transactions Views/UserView.swift
👥 Identifying the user ViewModels/UserViewModel.swift
🚪 Logging out the user ViewModels/UserViewModel.swift

Setup & Run

Prerequisites

Steps to Run

  1. Open the file Magic Weather SwiftUI.xcworkspace in Xcode.

  2. On the General tab of the project editor, match the bundle ID to your bundle ID in App Store Connect and RevenueCat.

    General tab in Xcode
  3. On the Signing & Capabilities tab of the project editor, select the correct development team from the Team dropdown.

    Signing & Capabilities tab in Xcode
  4. 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.
  5. Build the app and run it on your device.

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 Apple 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

Support

For more technical resources, check out our documentation.

Looking for RevenueCat Support? Visit our community.