Show a Paywall

There are many situations where you may want explicit control over when a paywall is displayed in your app. One common example would be any place in your app you have a button or action that should raise the in-app purchase options.

Raising a paywall is done by launching a campaign that contains the paywall. The launch method will make sure the paywall has all the data it needs to load.

Basics

A basic call looks like this:

NamiCampaignManager.launch()

This will display the paywall configured in your default live campaign, as set up in the Control Center.

Launching a Specific Campaign

If you have multiple paywalls for specific use cases, you will want to create multiple campaigns and give them labels. You can then launch a campaign by its label as follows:

NamiCampaignManager.launch(label: "YOUR_CAMPAIGN_LABEL")

Errors

The following errors may be returned by the launch method.

@objc enum PreparePaywallError : Int {
  case PAYWALL_ALREADY_DISPLAYED = 0
  case DATA_NOT_AVAILABLE = 1
  case NO_LIVE_CAMPAIGN = 2
  case IMAGE_LOAD_FAILED = 3
  case CAMPAIGN_LABEL_NOT_FOUND = 4
  case SDK_NOT_INITIALIZED = 5
  case PRODUCT_LOAD_FAILED = 6
}

What these errors mean:

  • PAYWALL_ALREADY_DISPLAYED - for Paywall Creator paywalls, you will get this error if another paywall is already displayed. This error does not occur for Linked Paywalls.
  • DATA_NOT_AVAILABLE - this error occurs when some data required by the SDK were not available. This most commonly occurs when the data returned by the Nami.configure call is not available yet.
  • NO_LIVE_CAMPAIGN - The Nami SDK requires a campaign to be live in the Control Center for correct functioning. If there is currently no live campaign, you will get this error.
  • IMAGE_LOAD_FAILED - this error will only occur if the paywall image was not able to be downloaded before the waitOnData timeout was reached.
  • CAMPAIGN_LABEL_NOT_FOUND - this error will occur when there are no campaigns to be found using the campaign label you have passed to launch
  • SDK_NOT_INITIALIZED - you must call the Nami.configure method before the SDK will work. If you haven't made this call before you try to raise a paywall, you will get this error.
  • PRODUCT_LOAD_FAILED - The Nami SDK calls StoreKit to get products for the paywall. If this call times out, you will get this error