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) If set, 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 (e.g. an amplitude user id, or a custom user id from your own analytics service)
(Optional) RevenueCat ONLY. Supply RevenueCat appUserID here (and initialize RevenueCat before Helium initialize). You can also set this value outside of initialize: HeliumFlutter().setRevenueCatAppUserId(await Purchases.appUserID)
Set these values before or during initialize to ensure consistency in analytics events and for the best experimentation results.
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.
After initialization, you can check the status of the paywalls download:
Do not call presentUpsell in Widget build() as this can have unpredictable behavior.
You can also pass in event handlers and custom paywall traits directly to presentUpsell:
Copy
Ask AI
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. }, ), customPaywallTraits: { "has_seen_intro_video": true, });
Looking for alternative presentation methods? Check out the guide on Ways to Show a Paywall.
You should now be able to see Helium paywalls in your app! Well done! 🎉
By default, Helium will handle purchase logic for you. If you want a custom implementation, you’ll want to implement HeliumPurchaseDelegate and pass that into initialize.
Copy
Ask AI
abstract class HeliumPurchaseDelegate { Future<HeliumPurchaseResult> makePurchase(String productId); Future<bool> restorePurchases();}
Use these methods to check current user subscription status.
Copy
Ask AI
/// 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 provided trigger./// - Parameter trigger: Trigger that would be used to show the paywall./// - Returns: `true` if the user has bought one of the products on the paywall./// `false` if not. Returns `null` if not known (i.e. the paywall is not downloaded yet).Future<bool?> hasEntitlementForPaywall(String trigger) => HeliumFlutterPlatform.instance.hasEntitlementForPaywall(trigger);
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.