Skip to main content
Version: 3.0

iOS - Present Paywall Builder paywalls

If you've customized a paywall using the Paywall Builder, you don't need to worry about rendering it in your mobile app code to display it to the user. Such a paywall contains both what should be shown within the paywall and how it should be shown.

note

Present paywalls in Swift

In order to display the visual paywall on the device screen, you must first configure it. To do this, use the method .paywallController(for:products:introductoryOffersEligibilities:viewConfiguration:delegate:):

Swift
import Adapty
import AdaptyUI

do {
let visualPaywall = try AdaptyUI.paywallController(
for: <paywall object>,
products: <paywall products array>,
introductoryOffersEligibilities: <intro offers eligibilities dictionary>,
viewConfiguration: <LocalizedViewConfiguration>,
delegate: <AdaptyPaywallControllerDelegate>
)
} catch {
// handle the error
}

Request parameters:

ParameterPresenceDescription
PaywallrequiredAn AdaptyPaywall object to obtain a controller for the desired paywall.
ProductsoptionalProvide an array of AdaptyPaywallProducts to optimize the display timing of products on the screen. If nil is passed, AdaptyUI will automatically fetch the necessary products.
IntroductoryOffersEligibilitiesoptionalProvide the dictionary of offers eligibilities to optimize the display timing of offers eligibilities on the screen. If nil is passed, AdaptyUI will automatically fetch the necessary offers eligibilities.
ViewConfigurationrequiredAn AdaptyUI.LocalizedViewConfiguration object containing visual details of the paywall. Use the AdaptyUI.getViewConfiguration(paywall:locale:) method. Refer to Fetch Paywall Builder paywalls and their configuration topic for more details.
DelegaterequiredAn AdaptyPaywallControllerDelegate to listen to paywall events. Refer to Handling paywall events topic for more details.
TagResolveroptionalDefine a dictionary of custom tags and their resolved values. Custom tags serve as placeholders in the paywall content, dynamically replaced with specific strings for personalized content within the paywall. Refer to Custom tags in paywall builder topic for more details.
TimerResolveroptionalPass the resolver here if you are going to use custom timer functionality.

Returns:

ObjectDescription
AdaptyPaywallControllerAn object, representing the requested paywall screen

After the object has been successfully created, you can display it on the screen of the device:

Swift
present(visualPaywall, animated: true)

Present paywalls in SwiftUI

In order to display the visual paywall on the device screen, use the .paywall modifier in SwiftUI:

SwiftUI
@State var paywallPresented = false

var body: some View {
Text("Hello, AdaptyUI!")
.paywall(
isPresented: $paywallPresented,
paywall: <paywall object>,
viewConfiguration: <LocalizedViewConfiguration>,
didPerformAction: { action in
switch action {
case .close:
paywallPresented = false
default:
// Handle other actions
break
}
},
didFinishPurchase: { product, profile in paywallPresented = false },
didFailPurchase: { product, error in /* handle the error */ },
didFinishRestore: { profile in /* check access level and dismiss */ },
didFailRestore: { error in /* handle the error */ },
didFailRendering: { error in paywallPresented = false }
)
}

Request parameters:

ParameterPresenceDescription
PaywallrequiredAn AdaptyPaywall object to obtain a controller for the desired paywall.
ProductoptionalProvide an array of AdaptyPaywallProducts to optimize the display timing of products on the screen. If nil is passed, AdaptyUI will automatically fetch the necessary products.
IntroductoryOffersEligibilitiesoptionalProvide the dictionary of offers eligibilities to optimize the display timing of offers eligibilities on the screen. If nil is passed, AdaptyUI will automatically fetch the necessary offers eligibilities.
ConfigurationrequiredAn AdaptyUI.LocalizedViewConfiguration object containing visual details of the paywall. Use the AdaptyUI.getViewConfiguration(paywall:locale:) method. Refer to Fetch Paywall Builder paywalls and their configuration topic for more details.
TagResolveroptionalDefine a dictionary of custom tags and their resolved values. Custom tags serve as placeholders in the paywall content, dynamically replaced with specific strings for personalized content within the paywall. Refer to Custom tags in paywall builder topic for more details.
TimerResolveroptionalPass the resolver here if you are going to use custom timer functionality.

Closure parameters:

Closure parameterDescription
didFinishPurchaseIf Adapty.makePurchase() succeeds, this callback will be invoked.
didFailPurchaseIf Adapty.makePurchase() fails, this callback will be invoked.
didFinishRestoreIf Adapty.restorePurchases() succeeds, this callback will be invoked.
didFailRestoreIf Adapty.restorePurchases() fails, this callback will be invoked.
didFailRenderingIf an error occurs during the interface rendering, this callback will be invoked.

Refer to the iOS - Handling events topic for other closure parameters.