Superwall iOS SDK

repository·develop·Indexed 41 days ago

https://github.com/superwall/superwall-ios

A platform and SDK for remotely configuring and iterating on in-app paywalls without app updates. SuperwallKit provides a WebKit wrapper for presenting web-based paywalls, featuring built-in analytics, A/B testing, and integration options for RevenueCat. Supports UIKit and SwiftUI, with installation available via Swift Package Manager (v4.0.0+) and Cocoapods (< 5.0.0).

Tokens
1.9K
Snippets
5
Records
15
Agent score
52%

What's inside Superwall

  1. Overview of SuperwallKit

    develop

    SuperwallKit is the client SDK for Superwall, a service designed to let you remotely configure, present, and iterate on paywalls within your iOS application. It supports both UIKit and SwiftUI.

    To get started, you must:

    1. Sign up for a Superwall account.
    2. Configure the SDK using your API key.
    3. Register placements in your code.
    4. Present paywalls in response to those placements.

    Once configured, you can manage paywalls via the Superwall dashboard using the paywall editor and define when they appear using Campaigns and Audiences.

  2. What is SuperwallKit?

    develop
    SuperwallKit is an open source framework that provides a wrapper around WebKit for presenting and creating paywalls. It allows you to remotely configure paywalls via the Superwall backend, enabling you to iterate on paywall designs and logic in real-time without requiring a new app store submission.
  3. Install SuperwallKit via Swift Package Manager

    develop

    Swift Package Manager (SPM) is the preferred installation method. To install SuperwallKit in Xcode:

    1. Select File ▸ Add Packages...
    2. Search for https://github.com/superwall/Superwall-iOS in the search bar.
    3. Set the Dependency Rule to Up to Next Major Version with the lower bound set to 4.0.0.
    4. Ensure your project name is selected in Add to Project.
    5. Click Add Package.
  4. Configure the Superwall SDK

    develop

    Before using any features of the SDK, you must initialize it using the Superwall.configure method. This is typically done once during your app's startup sequence. You can provide an API key, a custom PurchaseController, and additional SuperwallOptions.

    // Basic configuration
    Superwall.configure(apiKey: "YOUR_API_KEY")
    
    // Advanced configuration with options and completion handler
    Superwall.configure(
        apiKey: "YOUR_API_KEY",
        purchaseController: myPurchaseController,
        options: myOptions
    ) { result in
        // Handle configuration result
    }
  5. Present a Paywall using placements

    develop

    To show a paywall to a user, use the register(placement:) method. You can pass specific parameters to the placement to customize the paywall experience or provide a handler to react to the presentation result.

    Common methods include:

    • register(placement:): The simplest way to trigger a paywall for a specific placement.
    • register(placement:params:): Triggers a paywall with custom parameters.
    • register(placement:params:handler:): Triggers a paywall and provides a callback to handle the outcome.
    // Register a placement to show a paywall
    Superwall.shared.register(placement: "premium_upsell")
    
    // Register with parameters and a handler
    Superwall.shared.register(placement: "onboarding_paywall", params: ["user_type": "new"]) { result in
        switch result {
        case .presented: 
            print("Paywall was shown")
        case .dismissed: 
            print("Paywall was dismissed")
        case .skipped(let reason): 
            print("Paywall skipped: \(reason)")
        }
    }
  6. Install SuperwallKit via Cocoapods

    develop

    To include the Superwall SDK in your project using Cocoapods, add the following line to your Podfile:

    pod 'SuperwallKit', '< 5.0.0'

    After updating your Podfile, run the following commands in your terminal:

    1. pod repo update to update your local spec repo.
    2. pod install to install the dependency.
    pod 'SuperwallKit', '< 5.0.0'
  7. Choose an example app for Superwall integration

    develop

    Superwall provides two distinct example applications to demonstrate different integration levels:

    • Basic Example App: Best for developers who want Superwall to handle the entire paywall and subscription lifecycle automatically.
    • Advanced Example App: Best for developers who require granular control, such as managing entitlements manually, controlling the purchasing/restore process, or integrating with RevenueCat.