Skip to main content

SDK Quickstart

Get up and running with mobile subscriptions

AIAsk AIChatGPTClaude

This guide shows you how to get up and running with subscriptions and the RevenueCat SDK with only a few lines of code.

Prerequisites

You need the following before you start:

1. Install the RevenueCat SDK

The RevenueCat SDK implements purchases and subscriptions across platforms while syncing tokens with the RevenueCat server.

Choose your mobile app platform to install the RevenueCat SDK, then return here to initialize and configure the SDK.

SDK Installation Guides →

2. Initialize and configure the RevenueCat SDK

Initialize Purchases with your public API key:

// on iOS and tvOS, use `application:didFinishLaunchingWithOptions:`
// on macOS and watchOS use `applicationDidFinishLaunching:`

func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {

Purchases.logLevel = .debug
Purchases.configure(withAPIKey: <revenuecat_project_apple_api_key>, appUserID: <app_user_id>)

return true
}

Configure the shared instance of Purchases once, usually on app launch. After that, access the same instance anywhere in your app through .shared.

Identifying users

The app_user_id field in .configure is how RevenueCat identifies the Customers of your app. If your app has a user authentication system, you can provide a user identifier here at configuration time or later with a call to .logIn(). Omit this value for RevenueCat to generate an anonymous ID for you.

For more information, see our Identifying Users guide.

📘Have existing purchase code?

If you're planning to use RevenueCat alongside your existing purchase code, be sure to tell the SDK that your app will complete the purchases.

3. Check subscription status

Your app should check the Customer's subscription status whenever it decides which UI to show, typically on app launch and before presenting a paywall, so Customers who are already subscribed aren't asked to purchase again.

Check the Customer's CustomerInfo object to see if a specific Entitlement is active, or check whether the active Entitlements array contains a specific Entitlement ID.

// Using Swift Concurrency
let customerInfo = try await Purchases.shared.customerInfo()
if customerInfo.entitlements.all[<your_entitlement_id>]?.isActive == true {
// User is "premium"
}
// Using Completion Blocks
Purchases.shared.getCustomerInfo { (customerInfo, error) in
if customerInfo?.entitlements.all[<your_entitlement_id>]?.isActive == true {
// User is "premium"
}
}

You can use this method whenever you need the latest status, and it's safe to call repeatedly throughout the lifecycle of your app. The RevenueCat SDK automatically caches the latest CustomerInfo whenever it updates, so in most cases this method pulls from the cache.

In a new integration, no Entitlements are active yet. That's the signal to present a paywall, which is the next step.

4. Present a Paywall

The SDK automatically fetches your configured Offerings and retrieves product information from your Test Store or connected stores (Apple, Google, etc.). You can present a paywall using RevenueCat's pre-built UI or build your own.

RevenueCat provides customizable paywall templates that you can configure remotely.

  1. Create a RevenueCat Paywall
  2. Display the Paywall
📘Build your own paywall

If you prefer full control, manually display products, then handle purchases.

5. Make a purchase

Once your paywall is presented, select one of your products to make a purchase. The RevenueCat SDK handles the purchase flow automatically and sends the purchase information to RevenueCat.

Testing with the Test Store:

  • Test Store purchases work immediately without any additional setup.
  • They behave like real subscriptions in your app.
  • No real money is charged.

Testing with real stores:

  • The RevenueCat SDK automatically handles sandbox vs. production environments.
  • Each platform requires slightly different configuration steps to test in sandbox.

See Sandbox Testing for platform-specific instructions.

6. Verify the purchase in RevenueCat

When a purchase is complete, you can find the purchase associated with the Customer in the RevenueCat dashboard.

  1. Log in to the RevenueCat dashboard.
  2. Open the Customers page.
  3. Verify the purchase by searching for the Customer by their App User ID or $RCAnonymousID.

Customer details

📘Transaction validation

RevenueCat always validates transactions. Test Store purchases are validated by RevenueCat; real store purchases are validated by the respective platform (Apple, Google, etc.).

The RevenueCat SDK automatically updates the Customer's CustomerInfo object with the new purchase information. This object contains all the information about the Customer's purchases and subscriptions.

To see the change in your app, run the status check from step 3 again. The Entitlement attached to your product is now active.

7. React to subscription status changes

You can respond to any changes in a Customer's CustomerInfo by conforming to an optional delegate method: purchases:receivedUpdated:.

This method fires whenever the RevenueCat SDK receives an updated CustomerInfo object from calls to getCustomerInfo(), purchase(package:), purchase(product:), or restorePurchases().

// Additional configure setup
// on iOS and tvOS, use `application:didFinishLaunchingWithOptions:`
// on macOS and watchOS use `applicationDidFinishLaunching:`

func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {

Purchases.logLevel = .debug
Purchases.configure(withAPIKey: <revenuecat_api_key>)
Purchases.shared.delegate = self // make sure to set this after calling configure

return true
}

extension AppDelegate: PurchasesDelegate {
func purchases(_ purchases: Purchases, receivedUpdated customerInfo: CustomerInfo) {
/// - handle any changes to the user's CustomerInfo
}
}
📘Delegate method

RevenueCat does not push CustomerInfo updates to your app; updates only happen when the SDK makes an outbound network request to RevenueCat.

Depending on your app, it may be sufficient to ignore the delegate and handle changes to customer information the next time your app is launched or in the completion blocks of the SDK methods.

8. Restore purchases

Your Customers can restore their in-app purchases, reactivating any content that they previously purchased from the same store account (Apple, Google, etc.).

By default, RevenueCat Paywalls include a Restore Purchases button, so there's no code to write. If you built your own paywall, you can trigger a restore programmatically. See Restoring Purchases for the SDK methods.

📘Restoring transactions from the same store account

If two different App User IDs restore transactions from the same store account, the default behavior is to merge (alias) the identities for anonymous users, and transfer the subscription between identified users. See our guide on Restoring Purchases for more information on the different configurable restore behaviors.

Sample apps

For more complete examples of integrating the SDK, see our sample apps.

View Sample Apps →

Troubleshooting

During development, we recommend enabling more verbose debug logs.

If you run into issues with the SDK, see Troubleshooting the SDKs for guidance.

Next steps

  • If you want to use your own user identifiers, read about setting App User IDs.
  • To learn how restores work and the configurable restore behaviors, see our guide on Restoring Purchases.
  • Once you're ready to test your integration, follow our guides on testing and debugging.
  • If you're moving to RevenueCat from another system, see our migration guide.
  • If you qualify for the App Store Small Business Program, check out our guide on how to apply.
  • See our guide on Subscription Status to learn whether a subscription is set to renew, whether there's an issue detected with the Customer's credit card, and more.
  • For more information and best practices for configuring the SDK, see our guide on configuring the SDK.
Was this page helpful?