Using RevenueCat
If you want to use RevenueCat to handle your subscription-related logic with Superwall, follow this guide.
Not using RevenueCat? No problem! Superwall works out of the box without any additional SDKs.
Integrate RevenueCat with Superwall in one of two ways:
- Using a purchase controller: Use this route if you want to maintain control over purchasing logic and code.
- Using PurchasesAreCompletedBy: Here, you don’t use a purchase controller and you tell RevenueCat that purchases are completed by your app using StoreKit 1. In this mode, RevenueCat will observe the purchases that the Superwall SDK makes. For more info see here.
1. Create a PurchaseController
Create a new file called RCPurchaseController.swift
or RCPurchaseController.kt
, then copy and paste the following:
As discussed in Purchases and Subscription Status, this PurchaseController
is responsible for handling the subscription-related logic. Take a few moments to look through the code to understand how it does this.
2. Configure Superwall
Initialize an instance of RCPurchaseController
and pass it in to Superwall.configure(apiKey:purchaseController)
:
3. Sync the subscription status
Then, call purchaseController.syncSubscriptionStatus()
to keep Superwall’s subscription status up to date with RevenueCat.
That’s it! Check out our RevenueCat iOS example app for a working example of this integration.
Using PurchasesAreCompletedBy
If you’re using RevenueCat’s PurchasesAreCompletedBy, you don’t need to create a purchase controller. Register your placements, present a paywall — and Superwall will take care of completing any purchase the user starts. However, there are a few things to note if you use this setup:
- Here, you aren’t using RevenueCat’s entitlements as a source of truth. If your app is multiplatform, you’ll need to consider how to link up pro features or purchased products for users.
- If you require custom logic when purchases occur, then you’ll want to add a purchase controller. In that case, Superwall handles purchasing flows and RevenueCat will still observe transactions to power their analytics and charts.
- Be sure that user identifiers are set the same way across Superwall and RevenueCat.
- Finally, make sure that RevenueCat is using StoreKit 1.
Example:
For more information on observer mode, visit RevenueCat’s docs.