Integrate Helium into your iOS App
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.
Install helium-swift via SPM. In Xcode, go to Add Package Dependencies, and copy in https://github.com/cloudcaptainai/helium-swift.git
Set the Dependency Rule to Up to Next Major Version (use the default range which should be between 2.x.x and 3.0.0):
When asked to Choose Package Products for helium-swift, find the Helium row and set the Add to Target column value to your app’s main target.
If you are using RevenueCat to manage purchases, then we recommended you also add HeliumRevenueCat to your target so that you can use our RevenueCatDelegate referenced below.
Then select Add Package.
To integrate Helium paywalls, create a subclass of HeliumPaywallDelegate
or use one of our pre-built delegates from the next section. This class is responsible for handling the purchase logic for your paywalls.
HeliumPaywallTransactionStatus is an enum that defines the possible states of a paywall transaction.
Use the StoreKitDelegate to handle purchases using native StoreKit 2:
If you would like to implement onHeliumPaywallEvent
, simply create a subclass of StoreKitDelegate.
If you would like to implement onHeliumPaywallEvent
, simply create a subclass of RevenueCatDelegate. Make sure to initialize RevenueCat before initializing Helium or alternatively you can supply your RevenueCat API key to RevenueCatDelegate() and have Helium initialize RevenueCat for you.
Somewhere in your app’s initialization code (e.g. your main App
if using SwiftUI, or AppDelegate
if using ViewController), add the following line to actually download paywall config/variants.
We schedule it 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.
HeliumUserTraits is a struct that defines the possible user traits that can be passed in. It can be created with any dictionary, as long as the key is a string and the value is a Codable
type.
By default, Helium generates a UUID per app session and identifies each user + interaction with this. You can pass override this value with a custom user id (e.g. from a 3rd party analytics service)
by passing it in as a parameter in Helium.shared.initializeAndFetchVariants
, or by explicitly calling Helium.shared.overrideUserId
:
After the initialization code above runs, you can check the status of the paywall configuration download using the Helium.shared.downloadStatus()
method. This method returns a value of type HeliumFetchedConfigStatus
, which is defined as follows:
notDownloadedYet
: Indicates that the download has not been initiated or is still in progress.
downloadSuccess(fetchedConfigId: UUID)
: Indicates a successful download. The returned fetchedConfigID
provides the UUID of the fetched configuration.
downloadFailure
: Indicates that the download attempt failed.
You can use this to handle different states in your app, for example:
Now, anywhere in your iOS app, you can use the triggerUpsell
modifier to (conditionally) trigger a Helium paywall!
You can use the .triggerUpsell
view modifier from any SwiftUI view. It can be provided with a boolean binding var parameter to control the visibility of the paywall.
In addition to using the triggerUpsell modifier, you can also present upsells programmatically using the presentUpsell(trigger:)
method. This is particularly useful when you need to show a paywall in response to a specific action or event in your app.
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
.
By default, Helium uses a DismissAction
to support dismissing the paywall. However, in cases where you want to control dismissal yourself (e.g. if you’re using a custom ViewController, or a NavigationStack),
you can use HeliumPaywallDelegate
to wire up dismissal (or any custom action!) events from a given paywall.
To wire up actions, implement the onCTAPressed
method as follows:
How it works is that any component (e.g. an X out icon, decline text, etc.) can be remotely configured to be a wrapped in a Button
with a name. When this button component
is tapped, we fire the delegate’s onCTAPressed
method with the button name. So, once you’ve implemented custom swift code from your delegate, you can remotely configure
components in the paywall to trigger those methods.
Docs here coming soon! After integration, please message us directly to get set up with a test app + in-app test support.
Triggered when a user presses a Call-To-Action (CTA) button on the paywall.
ctaName
: The name or identifier of the CTA button pressed.triggerName
: The name of the trigger that initiated the paywall.paywallTemplateName
: The name of the paywall template being used.Triggered when a user selects a specific offer or product.
productKey
: The key or identifier of the selected product or offer.triggerName
: The name of the trigger that initiated the paywall.paywallTemplateName
: The name of the paywall template being used.Triggered when a user presses the subscribe button for a specific product.
productKey
: The key or identifier of the product being subscribed to.triggerName
: The name of the trigger that initiated the paywall.paywallTemplateName
: The name of the paywall template being used.Triggered when a subscription process is cancelled by the user.
Triggered when a subscription is successfully completed.
Triggered when the subscription process fails for any reason. error
will be the localizedDescription of the underlying
error returned by HeliumPaywallDelegate.makePurchase().
Triggered when a previous subscription is successfully restored.
Triggered when a subscription is in a pending state (e.g., waiting for approval).
Triggered when a paywall is successfully opened and displayed to the user.
Triggered when there’s an error opening or displaying the paywall.
Triggered when the paywall is closed programmatically.
Triggered when the user dismisses the paywall.
Triggered when paywall configurations are successfully downloaded.
configId
: The unique identifier of the downloaded configuration.Triggered when there’s an error downloading paywall configurations.
error
: A string describing the error that occurred during download.Note: For all events related to subscriptions and paywall interactions, the following parameters are consistently used:
productKey
: Identifies the specific product or subscription tier.triggerName
: Indicates what caused the paywall to be displayed.paywallTemplateName
: Specifies which paywall design template is being used.