RevenueCat

Build With RevenueCat

Build a customized mobile subscription business with RevenueCat. We do the heavy lifting of normalizing subscribers from any source and maintain a single source of truth for subscription status, so you can get back to building your app.

RevenueCat is a powerful, secure, reliable, and free to use in-app purchase server with global support. All you need to get started is an API key.

Get Started    API Reference

Configuring the SDK

If this is your first time integrating RevenueCat into your app, we recommend following our Quickstart guide.

Basic Configuration

Initialization

Once you've installed the Purchases SDK for your app, it's time to initialize and configure it.

You should only configure Purchases once, usually early in your application lifecycle. After configuration, the same instance is shared throughout your app by accessing the .shared instance in the SDK.

Make sure you configure Purchases with your public SDK key only. You can read more about the different API keys available in our Authentication guide.

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
  
    Purchases.debugLogsEnabled = true
    Purchases.configure(withAPIKey: "public_sdk_key")
  
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.
    
    RCPurchases.debugLogsEnabled = YES;
    [RCPurchases configureWithAPIKey:@"public_sdk_key"];
    
    return YES;
}
class MainApplication: Application() {

    override fun onCreate() {
        super.onCreate()
        Purchases.debugLogsEnabled = true
        Purchases.configure(this, "public_sdk_key")
    }

}
public class MainApplication extends Application {

    @Override
    public void onCreate() {
        super.onCreate();
        Purchases.debugLogsEnabled = true;
       Purchases.configure(this, "public_sdk_key");
    }

}
Future<void> initPlatformState() async {
  await Purchases.setDebugLogsEnabled(true);
  await Purchases.setup("public_sdk_key");
}
export default class App extends React.Component {
  
  componentDidMount() {
    Purchases.setDebugLogsEnabled(true);
    Purchases.setup("public_sdk_key");
  }
  
}
document.addEventListener("deviceready", onDeviceReady, false);

function onDeviceReady() {
    Purchases.setDebugLogsEnabled(true);
    Purchases.setup("public_sdk_key");
}
See Unity installation instructions https://docs.revenuecat.com/docs/unity

📘

SwiftUI App Protocol

Using SwiftUI's App protocol? Check out our resource on setting up the Purchases SDK with SwiftUI.

Enabling Debug Logs

Be sure to enable and view debug logs before filing a ticket with RevenueCat Support.

As detailed in the sample code above, debug logs can be enabled or disabled by setting the debugLogsEnabled property before configuring Purchases.

Debug logs will provide detailed log output in Xcode or LogCat for what is going on behind the scenes and should be the first thing you check if your app is behaving unexpectedly, and also to confirm there aren't any unhandled warnings or errors.

Additional Configuration Options

The Purchases SDK allows additional configuration on first setup:

  • API Key (required): The public API key found in your app Settings in the RevenueCat dashboard
  • App User Id (optional): An identifier for the current user. Pass null if you don't have a user identifier at the time of configuration and RevenueCat will generate an anonymous Id for you. See our guide on identifying users for more info.
  • Observer Mode (optional): A boolean value to set Purchases in Observer Mode. Only pass true if you're using RevenueCat for analytics purposes, and you're handling making purchases and checking subscription status yourself.
  • User Defaults (optional, iOS only): A key to override the standard user defaults used to cache the purchaser info. This is required if you need to access purchaser info in an iOS App Extension.

If you're planning to use RevenueCat alongside your existing purchase code, check out our guide on Observer Mode.

Advanced Configuration

Additional configuration options on the .shared instance of Purchases.

iOS


PROPERTY allowsSharingAppStoreAccount

When TRUE, if a new user tries to purchase a product that is already active on the current Apple account, this will treat it as a restore and alias the App User Ids together. Defaults to TRUE if the current App User Id is anonymous, and FALSE if you've provided an App User Id.


Delegates

DELEGATE didReceiveUpdatedPurchaserInfo

Called whenever Purchases receives an updated PurchaserInfo object. This may happen periodically throughout the life of the app if new information becomes available (e.g. after making a purchase).


DELEGATE shouldPurchasePromoProduct

Called when a user initiates a promotional in-app purchase from the App Store. If your app is able to handle a purchase at the current time, run the deferment block in this method. If the app is not in a state to make a purchase: cache the defermentBlock, then call the defermentBlock when the app is ready to make the promotional purchase. If the purchase should never be made, you don't need to ever call the defermentBlock and Purchases will not proceed with promotional purchases.

Android


PROPERTY allowsSharingPlayStoreAccount

When TRUE, if a new user tries to purchase a product that is already active on the current Play Store account, this will treat it as a restore and alias the App User Ids together. Defaults to TRUE if the current App User Id is anonymous, and FALSE if you've provided an App User Id.


Listeners

LISTENER UpdatedPurchaserInfoListener

Called whenever Purchases receives an updated PurchaserInfo object. This may happen periodically throughout the life of the app if new information becomes available (e.g. after making a purchase).

Updated about a month ago


Configuring the SDK


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.