Superwall

register()

A function that registers a placement that can be remotely configured to show a paywall and gate feature access.

Purpose

Registers a placement so that when it's added to a campaign on the Superwall Dashboard, it can trigger a paywall and optionally gate access to a feature.

Signature

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

Parameters

Prop

Type

Returns / State

This function returns Unit. If you supply a feature lambda, it will be executed according to the paywall's gating configuration, as described above.

Usage

func pressedWorkoutButton() {
  // remotely decide if a paywall is shown and if
  // navigation.startWorkout() is a paid-only feature
  Superwall.shared.register(placement: "StartWorkout") {
    navigation.startWorkout()
  }
}
fun pressedWorkoutButton() {
  // remotely decide if a paywall is shown and if
  // navigation.startWorkout() is a paid-only feature
  Superwall.instance.register("StartWorkout") {
    navigation.startWorkout()
  }
}
void pressedWorkoutButton() {
  // remotely decide if a paywall is shown and if
  // navigation.startWorkout() is a paid-only feature
  Superwall.shared.registerPlacement('StartWorkout', feature: () {
      navigation.startWorkout();
  });
}
// remotely decide if a paywall is shown and if
// navigation.startWorkout() is a paid-only feature
Superwall.shared.register({
  placement: 'StartWorkout',
  feature: () => {
    navigation.navigate('LaunchedFeature', {
      value: 'Non-gated feature launched',
    });
  } 
});

Register without feature gating:

Superwall.instance.register(
    placement = "onboarding_complete",
    params = mapOf("source" to "onboarding"),
    handler = this
)

How is this guide?

Edit on GitHub