register

fun Superwall.register(placement: String, params: Map<String, Any>? = null, handler: PaywallPresentationHandler? = null, feature: () -> Unit? = null)(source)

Registers an event to access a feature. When the event is added to a campaign on the Superwall dashboard, it can show a paywall.

This shows a paywall to the user when: An event you provide is added to a campaign on the Superwall Dashboard; the user matches a rule in the campaign; and the user doesn't have an active subscription.

Before using this method, you'll first need to create a campaign and add the event to the campaign on the Superwall Dashboard.

The paywall shown to the user is determined by the rules defined in the campaign. When a user is assigned a paywall within a rule, they will continue to see that paywall unless you remove the paywall from the rule or reset assignments to the paywall.

Parameters

placement

The name of the event you wish to register.

params

Optional parameters you'd like to pass with your event. These can be referenced within the rules of your campaign. Keys beginning with $ are reserved for Superwall and will be dropped. Values can be any JSON encodable value, URLs or Dates. Arrays and dictionaries as values are not supported at this time, and will be dropped. Defaults to null.

handler

An optional handler whose functions provide status updates for a paywall. Defaults to null.

feature

A completion block containing a feature that you wish to paywall. Access to this block is remotely configurable via the Superwall Dashboard. If the paywall is set to Non Gated, this will be called when the paywall is dismissed or if the user is already paying. If the paywall is Gated, this will be called only if the user is already paying or if they begin paying. If no paywall is configured, this gets called immediately. This will not be called in the event of an error, which you can detect via the handler.