Background
Get set up with the Helium SDK for Android. Reach out over your Helium slack channel or email founders@tryhelium.com for any questions.Installation
Add the Helium SDK to your project using Gradle.Requirements
- Kotlin Version: 2.0.0 or higher
- Java Version: 8 or higher
- Minimum Android SDK: 23 or higher
- Compile Android SDK: 35 or higher
1. Add repositories to your settings.gradle.kts file:
Ensure you have mavenCentral() and google() in your repositories blocks.
If you don’t have a
dependencyResolutionManagement block, ensure google() and mavenCentral() are present in your pluginManagement { repositories { ... } } block.2. Add the dependencies to your module-level build.gradle.kts file (e.g., app/build.gradle.kts):
- Core
- Jetpack Compose UI
- RevenueCat
Initialize Helium
Initialize the Helium SDK as early as possible in your app’s lifecycle.The supplied environment can be SANDBOX or PRODUCTION. If not sure, use PRODUCTION because Helium will automatically treat debug builds as SANDBOX.
- Application
- Activity
Helium’s initialization runs on a background thread, so you don’t have to worry about it affecting your app’s launch time.
Identifying Users
Identifying users is optional but can help with targeting and when forwarding events to external analytics platforms. If you are not sure, you probably do not need to identify your users. Set a custom user ID:Presenting Paywalls
You must have a trigger and workflow configured in the dashboard in order to show a paywall.
presentPaywall when you want to show a full-screen paywall. For example:
Looking for alternative presentation methods? Check out the guide on Ways to Show a Paywall.
PaywallEventHandlers
The Helium SDK allows you to listen for various paywall-related events. This is useful for tracking analytics, responding to user interactions, or handling the paywall lifecycle. There are two ways to listen for events: using thePaywallEventHandlers class for specific callbacks, or implementing the HeliumEventListener interface to receive all events.
Option 1: Using PaywallEventHandlers
You can create an instance ofPaywallEventHandlers and provide lambdas for the events you are interested in.
The available handlers are:
onOpen: Called when a paywall is displayed to the user.onClose: Called when a paywall is closed for any reason.onDismissed: Called when the user explicitly dismisses a paywall without purchasing.onPurchaseSucceeded: Called when a purchase completes successfully.onCustomPaywallAction: Called when a custom action is triggered from the paywall.onAnyEvent: Called for any of the above events.
Helium.shared.addPaywallEventListener. You can either tie the listener to a lifecycle (recommended) or manage it manually.
Lifecycle-Aware (Recommended) Pass a LifecycleOwner (like an Activity or Fragment) to have the listener automatically removed when the lifecycle is destroyed.
Option 2: Implementing HeliumEventListener
For a more centralized approach, your class can implement theHeliumEventListener interface and handle all events in a single onHeliumEvent method.
Purchase Handling
Use one of our pre-builtHeliumPaywallDelegate implementations or create a custom delegate. Set the delegate before calling initialize().
- PlayStorePaywallDelegate
- RevenueCatPaywallDelegate
- Custom Delegate
The PlayStorePaywallDelegate handles purchases using Google Play Billing:
Want to add some custom behavior but still use the built-in purchase logic? Just subclass
PlayStorePaywallDelegate or RevenueCatPaywallDelegate! (Be sure to make a super call for any overridden methods.)Consumables
This only applies if using the default
PlayStorePaywallDelegate for purchase handling. If you are using RevenueCatPaywallDelegate, configure RevenueCat to consume appropriate purchases. If you use a custom HeliumPaywallDelegate, you are responsible for consuming purchases.Checking Subscription Status & Entitlements
If you use an external payment processor like Stripe, Helium’s entitlement helpers may not be reliable. We recommend implementing your own entitlement checking in that case. If you use Stripe with RevenueCat, we recommend using RevenueCat’s entitlement APIs instead.
Entitlement Helper Methods
Entitlement Helper Methods
hasAnyEntitlement() Checks if the user has purchased any subscription or non-consumable product.hasAnyActiveSubscription() Checks if the user has any active subscription.hasEntitlementForPaywall(trigger: String) Checks if the user has entitlements for any product in a specific paywall. Returns null if paywall configuration hasn’t been downloaded yet.Example Usage
Fallbacks
It is highly recommended that you set up fallbacks in the uncommon case where a paywall fails to display. Please follow the linked guide to do so. Note that if you attempt to display a paywall while it is still being downloaded, a loading state will show. By default, Helium will show this loading state as needed (a shimmer view for up to 7 seconds). You can configure this behavior:PaywallOpenFailed event will be dispatched.
See the Fallbacks Guide for more details on downloading and configuring fallbacks.
Advanced
Checking Download Status
Checking Download Status
In most cases there is no need to check download status. Helium will display a loading indication if a paywall is presented before download has completed.
downloadStatus is a Kotlin Flow that emits HeliumConfigStatus states. The possible states are:HeliumConfigStatus.NotYetDownloaded: The initial state before the download has started.HeliumConfigStatus.Downloading: Indicates that the paywall configuration is currently being downloaded.HeliumConfigStatus.DownloadFailure: Indicates that the paywall configuration download has failed.HeliumConfigStatus.DownloadSuccess: Indicates that the paywall configuration has been successfully downloaded.
downloadStatus flow in your Activity or Fragment:Hiding Paywalls Programmatically
Hiding Paywalls Programmatically
You can programmatically hide paywalls using:
Reset Helium
Reset Helium
Reset Helium entirely so you can call initialize again. Only for advanced use cases.