(Optional) Called upon purchase success or purchase restore. If dontShowIfAlreadyEntitled is true, this handler will also be called when the paywall is not shown to users who already have entitlement for a product in the paywall.
(Optional) Called if desired paywall and fallback paywall did not show for any reason. This is uncommon, but best practice to handle it just in case. See Fallback Paywalls.
You should now be able to see Helium paywalls in your app! Well done! π
Looking for alternative presentation methods? Check out the guide on Ways to Show a Paywall.
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!
await initialize({ apiKey: '<your-helium-api-key>', // (Optional) Custom user id, e.g. your amplitude analytics user id. customUserId: '<your-custom-user-id>', // (Optional) Custom user traits customUserTraits: { "example_trait": "example_value", },});
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:
presentUpsell({ triggerName: 'my_paywall', eventHandlers: { onOpen: (event) => { console.log(`${event.type}`) }, onClose: (event) => { console.log(`${event.type}`) }, onPurchaseSucceeded: (event) => { console.log(`${event.type}`) }, onDismissed: (event) => { console.log(`${event.type}`) }, onOpenFailed: (event) => { console.log(`${event.type}`) }, onCustomPaywallAction: (event) => { console.log(`${event.type}`) }, 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) */export const hasAnyActiveSubscription = async (): Promise<boolean>;/** * Checks if the user has any entitlement */export const hasAnyEntitlement = async (): Promise<boolean>;/** * Checks if the user has an active entitlement for any product attached to * the paywall that will show for the provided trigger. * Returns undefined if not known (i.e. the paywall is not downloaded yet). */export const hasEntitlementForPaywall = async (trigger: string): Promise<boolean | undefined>;
By default, Helium will handle purchases for you! This section is typically for users who already use RevenueCat in their app.
Helium integrates seamlessly with RevenueCat so you can continue to let RevenueCat handle your purchases and entitlements.
If you havenβt already, make sure to install RevenueCat (for non-Expo see here).Make sure to initialize RevenueCat (Purchases.configure()) before initializing Helium.
Configure Helium to use RevenueCat by passing createRevenueCatPurchaseConfig to initialize:
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.
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.
import { resetHelium } from 'expo-helium';await resetHelium();
To verify that the Helium pod is correctly installed in your project, run:
grep -E "Helium" ios/Podfile.lock > /dev/null && echo "β Helium found in ios/Podfile.lock" || echo "β Helium not found in ios/Podfile.lock" && grep -E "HeliumPaywallSdk" ios/Podfile.lock > /dev/null && echo "β HeliumPaywallSdk found in ios/Podfile.lock" || echo "β HeliumPaywallSdk not found in ios/Podfile.lock"
If not found, try these commands:
# regenerate the ios (and android) directoriesnpx expo prebuild --clean# run a development buildnpx expo run:ios # or npx expo run:ios --device