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. The Android SDK requires an Application context for initialization.

Purpose

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

Signature

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

Parameters

NameTypeDescription
applicationApplicationYour Android Application instance, required for SDK initialization and lifecycle management.
apiKeyStringYour Public API Key from the Superwall dashboard settings.
purchaseControllerPurchaseController?Optional object for handling all subscription-related logic yourself. If null, Superwall handles subscription logic. Defaults to null.
optionsSuperwallOptions?Optional configuration object for customizing paywall appearance and behavior. See SuperwallOptions for details. Defaults to null.
completion(() -> Unit)?Optional completion handler called when Superwall finishes configuring. Defaults to null.

Returns / State

Configures the Superwall instance which is accessible via Superwall.instance.

Usage

// AppDelegate or SceneDelegate
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
    Superwall.configure(apiKey: "pk_your_api_key")
    return true
}

With custom options:

class MyApplication : Application() {
    override fun onCreate() {
        super.onCreate()
        
        val options = SuperwallOptions().apply {
            paywalls.shouldShowPurchaseFailureAlert = false
        }
        
        Superwall.configure(
            application = this,
            apiKey = "pk_your_api_key",
            options = options
        ) {
            println("Superwall configured successfully")
        }
    }
}

How is this guide?

On this page