Superwall

configure()

A static function that configures a shared instance of Superwall for use throughout your app.

This is a static method called on the Superwall class itself, not on the shared instance.

Purpose

Configures the shared instance of Superwall with your API key and optional configurations, making it ready for use throughout your app.

Signature

public static func configure(
  apiKey: String,
  purchaseController: PurchaseController? = nil,
  options: SuperwallOptions? = nil,
  completion: (() -> Void)? = nil
) -> Superwall

Parameters

NameTypeDescription
apiKeyStringYour Public API Key from the Superwall dashboard settings.
purchaseControllerPurchaseController?Optional object for handling all subscription-related logic yourself. If nil, Superwall handles subscription logic. Defaults to nil.
optionsSuperwallOptions?Optional configuration object for customizing paywall appearance and behavior. See SuperwallOptions for details. Defaults to nil.
completion(() -> Void)?Optional completion handler called when Superwall finishes configuring. Defaults to nil.

Returns / State

Returns the configured Superwall instance. The instance is also accessible via Superwall.shared.

Usage

Basic configuration:

Superwall.configure(apiKey: "pk_your_api_key")

With custom options:

let options = SuperwallOptions()
options.paywalls.shouldShowPurchaseFailureAlert = false

Superwall.configure(
  apiKey: "pk_your_api_key",
  options: options
) {
  print("Superwall configured successfully")
}

With custom purchase controller:

Superwall.configure(
  apiKey: "pk_your_api_key",
  purchaseController: MyPurchaseController()
)

How is this guide?

On this page