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.
(Optional) Delegate for handling your own purchase logic. If not provided, Helium will handle purchase logic for you. See the RevenueCat and Custom Purchase Handling sections.
(Optional) A custom user id to use instead of Helium’s. We’ll use this id when forwarding to third party analytics services, so this can be used for attribution. See Identifying Users section.
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.
Identify users as early as you can to maximize consistency in metrics and targeting. Ideally in your initialize call!
Helium dispatches various events during paywall presentation and purchase flow. You can optionally handle these events in your mobile app. You can also configure Helium to forward them to your existing analytics provider.
When displaying a paywall you can pass in event handlers to listen for select events:
HeliumFlutter().presentUpsell( trigger: 'my_paywall', context: context, eventHandlers: PaywallEventHandlers( onOpen: (event) { log('${event.type} - trigger: ${event.triggerName}'); }, onClose: (event) { log('${event.type} - trigger: ${event.triggerName}'); }, onDismissed: (event) { log('${event.type} - trigger: ${event.triggerName}'); }, onPurchaseSucceeded: (event) { log('${event.type} - trigger: ${event.triggerName}'); }, onAnyEvent: (event) { // A handler for all paywall-related events. // Note that if you have other handlers (i.e. onOpen) set up, // both that handler AND this one will fire during paywall open. }, ),);
/// Checks if the user has any active subscription (including non-renewable)Future<bool> hasAnyActiveSubscription();/// Checks if the user has any entitlementFuture<bool> hasAnyEntitlement();/// Checks if the user has an active entitlement for any product attached to/// the paywall that will show for the provided trigger./// Returns `null` if not known (i.e. the paywall is not downloaded yet).Future<bool?> hasEntitlementForPaywall(String trigger);
For the full public API and detailed parameter documentation, see the inline docstrings in the SDK source. Import Helium in your project and use your IDE’s autocomplete or jump-to-definition to explore all available methods and types.
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.
You can listen to the status of the paywalls download via a stream:
notDownloadedYet: The download has not been initiated.
inProgress: The download is in progress.
downloadSuccess: The download was successful.
downloadFailure: The download failed.
You can also check if paywalls have been downloaded with await heliumFlutter.paywallsLoaded()
Reset Helium
Reset Helium entirely so you can call initialize again, for example after changing user traits that can affect the paywalls a user might see via targeting.