Configuring the SDK

As soon as your app launches, you need to configure the SDK with your Public API Key. You'll retrieve this from the Superwall settings page.

If you haven't already, sign up for a free account on Superwall. Then, when you're through to the Dashboard, click Settings from the panel on the left, click Keys and copy your Public API Key:

Then, open AppDelegate.swift and call Superwall.configure(apiKey:) inside application(_:didFinishLaunchingWithOptions) with your API key. If you're using SwiftUI, you can call this on the init of your main App file:

import UIKit
import SuperwallKit

@main
final class AppDelegate: UIResponder, UIApplicationDelegate {
  func application(
    _ application: UIApplication,
    didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
  ) -> Bool {
    Superwall.configure(apiKey: "MY_API_KEY") // Replace this with your API Key
    return true
  }
}
import SwiftUI
import SuperwallKit

@main
struct MyApp: App {
  init() {
    let apiKey = "MY_API_KEY" // Replace this with your API Key
    Superwall.configure(apiKey: apiKey)
  }
  
  // etc...
}
@import SuperwallKit;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Initialize the Superwall service.
    [Superwall configureWithApiKey:@"MY_API_KEY"];
    return YES;
}

This configures a shared instance of Superwall, the primary class for interacting with the SDK's API. Make sure to replace MYAPIKEY with your public API key that you just retrieved.

📘

By default, Superwall handles basic subscription-related logic for you. However, if you’d like greater control over this process (e.g. if you’re using RevenueCat), you’ll want to pass in a PurchaseController to your configuration call and manually set the subscriptionStatus. You can also pass in SuperwallOptions to customize the appearance and behavior of the SDK. See Purchases and Subscription Status for more.

You've now configured Superwall!

For further help, check out our example apps for working examples of implementing SuperwallKit.