Superwall

PresentationResult

The result of a paywall presentation attempt.

Purpose

Represents the possible outcomes when checking or presenting a paywall. Used by getPresentationResult() and paywall presentation handlers.

Signature

sealed class PresentationResult {
  factory PresentationResult.placementNotFound() = PlacementNotFoundPresentationResult;
  factory PresentationResult.noAudienceMatch() = NoAudienceMatchPresentationResult;
  factory PresentationResult.paywall(Experiment experiment) = PaywallPresentationResult;
  factory PresentationResult.holdout(Experiment experiment) = HoldoutPresentationResult;
  factory PresentationResult.paywallNotAvailable() = PaywallNotAvailablePresentationResult;
}

class PlacementNotFoundPresentationResult extends PresentationResult;
class NoAudienceMatchPresentationResult extends PresentationResult;
class PaywallPresentationResult extends PresentationResult {
  final Experiment experiment;
}
class HoldoutPresentationResult extends PresentationResult {
  final Experiment experiment;
}
class PaywallNotAvailablePresentationResult extends PresentationResult;

Cases

Prop

Type

Experiment Information

When a paywall is presented or the user is in a holdout group, the result includes an Experiment object:

class Experiment {
  final String id;
  final String groupId;
}
  • id - The unique identifier for the experiment
  • groupId - The identifier for the experiment group the user is in

Usage

Handling different presentation results:

final result = await Superwall.shared.getPresentationResult('premium_feature');

if (result is PaywallPresentationResult) {
  // Paywall would be shown
  final experimentId = result.experiment.id;
  final groupId = result.experiment.groupId;
  print('Experiment: $experimentId, Group: $groupId');
} else if (result is HoldoutPresentationResult) {
  // User is in holdout
  print('User in holdout for experiment ${result.experiment.id}');
} else if (result is NoAudienceMatchPresentationResult) {
  // No audience match
  print('No audience match for placement');
} else if (result is PlacementNotFoundPresentationResult) {
  // Placement not found
  print('Placement not found');
} else if (result is PaywallNotAvailablePresentationResult) {
  // Paywall not available
  print('Paywall not available');
}

Using pattern matching:

final result = await Superwall.shared.getPresentationResult('premium_feature');

switch (result) {
  case PaywallPresentationResult(experiment: final exp):
    // Handle paywall presentation
    print('Paywall for experiment ${exp.id}');
  case HoldoutPresentationResult(experiment: final exp):
    // Handle holdout
    print('Holdout for experiment ${exp.id}');
  case NoAudienceMatchPresentationResult():
    // Handle no match
    print('No audience match');
  case PlacementNotFoundPresentationResult():
    // Handle not found
    print('Placement not found');
  case PaywallNotAvailablePresentationResult():
    // Handle not available
    print('Paywall not available');
}

How is this guide?

Edit on GitHub