Background
Get set up with the Helium SDK for Flutter. Reach out over your Helium slack channel or email founders@tryhelium.com for any questions.Installation
The minimum version of Flutter supported by this SDK is 3.24.0.
You can still use Cocoapods for your dependencies if preferred. If you need to disable Swift Package Manager dependencies after having enabled it, refer to that same Flutter documentation.
If you are using RevenueCat, you should also install the helium_revenuecat package so RevenueCat can handle purchases. See the section titled RevenueCat Purchase Delegate in this guide.
iOS Settings
Helium requires iOS 15+. If your app already has a minimum of iOS 15 or higher, you’re all set. This can be specified in yourios/Podfile with:
Initialize Helium
In your app’s initialization code (typically inmain.dart or your root widget), add the following to configure Helium and prepare your paywalls:
Custom User ID and Custom User Traits
Custom User ID and Custom User Traits
You can set a custom user ID and custom user traits with the Set these values before or during
initialize method or by calling:initialize to ensure consistency in analytics events and for the best experimentation results.Presenting Paywalls
You must have a trigger and workflow configured in the dashboard in order to show a paywall.
presentUpsell method:
presentUpsell:
Looking for alternative presentation methods? Check out the guide on Ways to Show a Paywall.
Helium Events
To handle various paywall-related events, implementHeliumCallbacks and pass it to initialize:
Handling Purchases
By default, Helium will handle purchase logic for you. If you want a custom implementation, you’ll want to implementHeliumPurchaseDelegate and pass that into initialize.
RevenueCat Purchase Delegate
If you are using RevenueCat, we recommend you use our built-in RevenueCat purchase delegate: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.
Example Usage
Fallbacks
The Flutter SDK currently has two fallback options - 1) Fallback bundle and 2) a fallback view. Fallback situations should be quite rare, but to be safe, it is highly recommended that you implement a fallback bundle or custom fallback view.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.
notDownloadedYet: The download has not been initiated.inProgress: The download is in progress.downloadSuccess: The download was successful.downloadFailure: The download failed.
await heliumFlutter.paywallsLoaded()Reset Helium
Reset Helium
Reset Helium entirely so you can call initialize again. Only for advanced use cases.