Skip to main content

Overview

Most of the time you’ll want to use presentPayall() (or presentUpsell() depending on your SDK version) to show paywalls. This approach is covered in each platform’s quickstart guide (see navigation menu on the left). But if you need more control over how and where paywalls appear in your app, there are a few other options.

iOS

Embedded View

HeliumPaywall(
    trigger: "onboarding"
) { paywallNotShownReason in
    Text("Paywall failed to show")
}
You’ll need to handle dismissal yourself when using this method. You can do so with PaywallEventHandlers.
HeliumPaywallView(
    trigger: "post_onboarding",
    eventHandlers: PaywallEventHandlers()
        .onOpen { event in
            print("open for trigger \(event.triggerName)")
        }
        .onClose { event in
            print("close for trigger \(event.triggerName)")
        }
        .onDismissed { event in
            // handle user dismissal here (i.e. navigate to another screen)
            print("dismiss for trigger \(event.triggerName)")
        }
        .onPurchaseSucceeded { event in
            print("purchase made for trigger \(event.triggerName)")
        }
        .onCustomPaywallAction { event in
            print("Custom action: \(event.actionName) with params: \(event.params)")
        }
) { paywallNotShownReason in
    Text("Paywall failed to show")
}

SwiftUI ViewModifier

Attach a paywall to any SwiftUI view using the .heliumPaywall view modifier:
struct ContentView: View {
    @State var isPresented: Bool = false
    var body: some View {
        VStack {
            Button {
                isPresented = true
            } label: {
                Text("Show paywall")
            }
        }.heliumPaywall(
            isPresented: $isPresented,
            trigger: "post_onboarding") { paywallNotShownReason in
                Text("Paywall failed to show")
            }
    }
}
If you are using UIKit, you can use a UIHostingController.

Android

Embedded Paywall (Compose)

HeliumPaywall(
    trigger = "onboarding",
    onPaywallNotShown = { reason ->
        Text("Paywall failed to show")
    }
)

Flutter

Widget Integration

Flutter embedded widget currently only works for iOS. Android support is in the works.
Embed a paywall directly in your widget tree using HeliumFlutter.getUpsellWidget:
class ExamplePageWithEmbeddedPaywall extends StatelessWidget {
  const ExamplePageWithEmbeddedPaywall({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: HeliumPaywall(
        trigger: "insert-trigger-here",
        paywallNotShownBuilder: (context, reason) => Text("Paywall failed to show"),
      ),
    );
  }
}
You will have to handle your own dismissal. You can do so by passing in PaywallEventHandlers and using the onDismissed handler.