Presenting a Paywall with UIKit

Call Paywall.present(onPresent:onDismiss:onFail:):

Paywall.present(
  onPresent: { info in
    // access info about the presented paywall
  },
  onDismiss: { didPurchase, productId, paywallInfo in
    // Add custom logic after paywall is dismissed
  },
  onFail: { error in
    // Log the error
    // Fallback to presenting your old paywall
  }
)

The onPresent, onDismiss, and onFail callbacks are optional. However, they provide the following information:

ParameterTypeFunctionality
onPresent(PaywallInfo?) → VoidCalled when the paywall is done presenting. PaywallInfo? contains things like the paywall's name, identifier and product_ids
onDismiss(didPurchase: Bool, productId: String?, info: PaywallInfo?) → VoidCalled when the paywall is dismissed (either by the user or because a purchase occurred).
If didPurchase is true, productId contains the id of the purchased product.
onFail(NSError?) → VoidCalled if an error occurs while showing your paywall, either because something is misconfigured, all paywalls are off, or if an unexpected response is received from our server. You should typically fallback to your previous paywall if this happens.

Occasionally you may want to specify a paywall or view controller to present the paywall on. These two parameters are also included in Paywall.present for these special occasions:

ParameterTypeFunctionalityDefault Behaviour
identifierStringThe identifier of a specific paywall you would like to show. We do NOT recommend using this – best to enable / disable paywalls from the dashboardAutomatically presents whatever paywall is on in the dashboard, in a round robin fashion.
onUIViewControllerThe view controller to present the paywall onAutomatically presents the paywall from a new window on top of the current window.

Presented paywalls are sticky – once a paywall is assigned to a user, they will see that paywall forever even if the paywall is turned off.

See Paywall Assignment for more information about how presented paywalls are assigned.


What’s Next