Background

Get set up with the Helium SDK for iOS in 5 minutes. Reach out over your Helium slack channel, or email founders@tryhelium.com for any questions.

Installation

We recommend using Swift Package Manager (SPM), but if your project primarily uses Cocoapods it might make sense to install the Helium Cocoapod instead.
  1. In Xcode, navigate to your project’s Package Dependencies: Spm Add Pn
  2. Click the + button and search for the Helim package URL:
    https://github.com/cloudcaptainai/helium-swift.git
    
  3. Click Add Package.
  4. In the dialog that appears, make sure to add the Helium product to your app’s main target: Spm Target Pn
  5. (Optional) If you are using RevenueCat to manage purchases, we recommended you also add HeliumRevenueCat to your target so that you can use our RevenueCatDelegate referenced below. Otherwise leave as None for the HeliumRevenueCat row.
The HeliumRevenueCat target includes purchases-ios-spm as a dependency, not purchases-ios and you may encounter build issues if are using purchases-ios with SPM.
  1. Select Add Package in the dialog and Helium should now be ready for import.

Initialize Helium

Initialize the Helium SDK as early as possible in your app’s lifecycle. Choose the appropriate location based on your app’s architecture:
@main
struct MyApp: App {
    init() {
        // ** Call Helium initialize here (see right below) **
    }

    var body: some Scene {
        WindowGroup {
            ContentView()
        }
    }
}
Add necessary imports:
import Helium
import SwiftUI
And initialize Helium in the location referenced above:
Helium.shared.initialize(
    apiKey: "<your-helium-api-key>",
    heliumPaywallDelegate: YourHeliumPaywallDelegate(), // see next section
    fallbackPaywall: Text("Fallback shown"),
    revenueCatAppUserId: Purchases.shared.appUserID // RevenueCat ONLY
)
Helium.shared.initialize
method
Helium’s initialization is ran on a background thread, so you don’t have to worry about it blocking your app’s launch time. Helium will automatically retry downloads as needed for up to 90 seconds.

HeliumPaywallDelegate

Create a subclass of HeliumPaywallDelegate or use one of our pre-built delegates. This class is responsible for handling the purchase logic for your paywalls and handling Helium Events.
Use the StoreKitDelegate to handle purchases using native StoreKit 2:
import Helium

let delegate = StoreKitDelegate(productIds: [
    "<product-id-1>",
    "<product-id-2>",
])
To handle Helium Events, simply create a subclass of StoreKitDelegate and override onHeliumPaywallEvent:
class MyStoreKitDelegate: StoreKitDelegate {
    override func onHeliumPaywallEvent(event: HeliumPaywallEvent) {
        switch event {
        case .paywallOpen(let triggerName, let paywallTemplateName, let viewType):
            break
        case .paywallClose(let triggerName, let paywallTemplateName):
            break
        case .paywallDismissed:
            break
        default:
            break
        }
    }
}

Presenting Paywalls

Now, anywhere in your iOS app, you can show a paywall and you have different options to do so.

Via Programmatic Invocation

Call Helium.shared.presentUpsell(trigger:) when you want to show the paywall. For example:
Button("Try Premium") {
    Helium.shared.presentUpsell(trigger: "post_onboarding")
}

Via SwiftUI ViewModifier

You can use the .triggerUpsell view modifier from any SwiftUI view:
struct ContentView: View {
    @State var isPresented: Bool = false
    var body: some View {
        VStack {
            Button {
                isPresented = true;
            } label: {
                Text("Show paywall")
            }

        }.triggerUpsell(isPresented: $isPresented, trigger: "post_onboarding")
    }
}

Explicitly getting the Helium Paywall View

You can also explicitly get the Helium paywall view via Helium.shared.upsellViewForTrigger. This method takes a trigger and returns the paywall as an AnyView.
let heliumView: AnyView = Helium.shared.upsellViewForTrigger(trigger: "post_onboarding")
You’ll need to handle presentation and dismissal yourself if you use this way of displaying paywalls. You can do so through Helium Events.

Testing

Docs here coming soon! After integration, please message us directly to get set up with a test app + in-app test support.