Skills cover SDK integration, building flows and paywalls, pre-publish audits, placement migration, and more. Describe the task in plain language and your agent picks the skill.
If you use Observer mode, you are responsible for your own purchase logic. But you can delegate the paywall UI to the Flow & Paywall Builder.
Design the screen in the builder, and the Adapty SDK renders it natively. Update its copy, layout, and pricing whenever you want, without an app release. When a user taps a purchase button, the SDK calls your code to complete the purchase.
This guide shows how to present that screen and handle the purchase call. If Adapty completes purchases for you, see Display flows & paywalls instead.
Before you start
You need:
Adapty iOS SDK v4 or later: Earlier versions can’t render flows. To move an existing app from v3, see the migration guide.
Don’t forget to associate paywalls to purchase transactions. Otherwise, Adapty will not determine the source paywall of the purchase. Pass the variationId of the AdaptyPaywallProduct the user bought, not AdaptyFlow.variationId: a flow’s own variation ID doesn’t link the purchase to the flow.
In SwiftUI, fetch the flow configuration with the resolver and pass it to the .flow modifier:
@State var flowPresented = false@State var flowConfiguration: AdaptyUI.FlowConfiguration?var body: some View { Button("Show flow") { flowPresented = true } .flow( isPresented: $flowPresented, flowConfiguration: flowConfiguration, didPerformAction: { action in switch action { case .close: flowPresented = false default: break } }, didFinishPurchase: { product, purchaseResult in /* dismiss, or do nothing to let the flow continue */ }, didFailPurchase: { product, error in /* handle the error */ }, didFinishRestore: { profile in /* check access level and dismiss */ }, didFailRestore: { error in /* handle the error */ }, didReceiveError: { error in flowPresented = false } ) .task { flowConfiguration = try? await AdaptyUI.getFlowConfiguration( forFlow: flow, preferredLocales: Locale.preferredLanguages, observerModeResolver: <AdaptyObserverModeResolver> ) }}
@State var flowPresented = false@State var flowConfiguration: AdaptyUI.FlowConfiguration?var body: some View { Button("Show flow") { flowPresented = true } .flow( isPresented: $flowPresented, flowConfiguration: flowConfiguration, didPerformAction: { action in switch action { case .close: flowPresented = false default: break } }, didFinishPurchase: { product, purchaseResult in /* dismiss, or do nothing to let the flow continue */ }, didFailPurchase: { product, error in /* handle the error */ }, didFinishRestore: { profile in /* check access level and dismiss */ }, didFailRestore: { error in /* handle the error */ }, didReceiveError: { error in flowPresented = false } ) .task { flowConfiguration = try? await AdaptyUI.getFlowConfiguration( forFlow: flow, observerModeResolver: <AdaptyObserverModeResolver> ) }}
The observerModeResolver: parameter on getFlowConfiguration is what makes the rendered flow respect your custom purchase logic — the modifier itself uses the same callbacks as full mode.
Warning
Don’t forget to associate paywalls to purchase transactions. Otherwise, Adapty will not determine the source paywall of the purchase. Pass the variationId of the AdaptyPaywallProduct the user bought, not AdaptyFlow.variationId: a flow’s own variation ID doesn’t link the purchase to the flow.
After onFinishPurchase(), the flow runs the When pendingoutcome actions whatever happened, a canceled purchase included. Show any screen that depends on the purchase result, such as a thank-you screen, from your code: only your code knows the result. After onFinishRestore(), the flow runs the When restore completed actions, whatever happened.
Before you start presenting paywalls (Click to Expand)
func observerMode(didInitiatePurchase product: AdaptyPaywallProduct, onStartPurchase: @MainActor @Sendable @escaping () -> Void, onFinishPurchase: @MainActor @Sendable @escaping () -> Void) { // use the product object to handle the purchase // use the onStartPurchase and onFinishPurchase callbacks to notify AdaptyUI about the process of the purchase}func observerModeDidInitiateRestorePurchases(onStartRestore: @MainActor @Sendable @escaping () -> Void, onFinishRestore: @MainActor @Sendable @escaping () -> Void) { // use the onStartRestore and onFinishRestore callbacks to notify AdaptyUI about the process of the restore}
The observerMode(didInitiatePurchase:onStartPurchase:onFinishPurchase:) event will inform you that the user has initiated a purchase. You can trigger your custom purchase flow in response to this callback.
The observerModeDidInitiateRestorePurchases(onStartRestore:onFinishRestore:) event will inform you that the user has initiated a restore. You can trigger your custom restore flow in response to this callback.
Also, remember to invoke the following callbacks to notify AdaptyUI about the process of the purchase or restore. This is necessary for proper paywall behavior, such as showing the loader, among other things:
Callback
Description
onStartPurchase()
The callback should be invoked to notify AdaptyUI that the purchase is started.
onFinishPurchase()
The callback should be invoked to notify AdaptyUI that the purchase is finished.
onStartRestore()
The callback should be invoked to notify AdaptyUI that the restore is started.
onFinishRestore()
The callback should be invoked to notify AdaptyUI that the restore is finished.
Create a paywall configuration object:
do { let paywallConfiguration = try AdaptyUI.getPaywallConfiguration( forPaywall: <paywall object>, observerModeResolver: <AdaptyObserverModeResolver> )} catch { // handle the error}
Request parameters:
Parameter
Presence
Description
Paywall
required
An AdaptyPaywall object to obtain a controller for the desired paywall.
ObserverModeResolver
required
The AdaptyObserverModeResolver object you’ve implemented in the previous step
Initialize the visual paywall you want to display by using the .paywallController(for:products:viewConfiguration:delegate:) method:
An AdaptyUI.PaywallConfiguration object containing visual details of the paywall. Use the AdaptyUI.getPaywallConfiguration(forPaywall:locale:) method. Refer to Fetch Paywall Builder paywalls and their configuration topic for more details.
Delegate
required
An AdaptyPaywallControllerDelegate to listen to paywall events. Refer to Handling paywall events topic for more details.
Returns:
Object
Description
AdaptyPaywallController
An object, representing the requested paywall screen
After the object has been successfully created, you can display it like so:
In order to display the visual paywall on the device screen, use the .paywall modifier in SwiftUI:
@State var paywallPresented = falsevar body: some View { Text("Hello, AdaptyUI!") .paywall( isPresented: $paywallPresented, paywallConfiguration: <paywall configuration object>, didPerformAction: { action in switch action { case .close: paywallPresented = false default: // Handle other actions break } }, didFinishRestore: { profile in /* check access level and dismiss */ }, didFailRestore: { error in /* handle the error */ }, didFailRendering: { error in paywallPresented = false } )}
Request parameters:
Parameter
Presence
Description
Paywall Configuration
required
An AdaptyUI.PaywallConfiguration object containing visual details of the paywall. Use the AdaptyUI.getPaywallConfiguration(forPaywall:locale:) method. Refer to Fetch Paywall Builder paywalls and their configuration topic for more details.
Products
optional
Provide an array of AdaptyPaywallProduct objects to optimize the display timing of products on the screen. If nil is passed, AdaptyUI will automatically fetch the necessary products.
TagResolver
optional
Define 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.
ObserverModeResolver
optional
The AdaptyObserverModeResolver object you’ve implemented in the previous step
Closure parameters:
Closure parameter
Description
didFinishRestore
If Adapty.restorePurchases() succeeds, this callback will be invoked.
didFailRestore
If Adapty.restorePurchases() fails, this callback will be invoked.
didFailRendering
If an error occurs during the interface rendering, this callback will be invoked.
Install and configure Adapty SDK. Make sure to set the observerMode parameter to true. Refer to our framework-specific instructions for iOS, React Native, Flutter, and Unity.
func paywallController(_ controller: AdaptyPaywallController, didInitiatePurchase product: AdaptyPaywallProduct, onStartPurchase: @escaping () -> Void, onFinishPurchase: @escaping () -> Void) { // use the product object to handle the purchase // use the onStartPurchase and onFinishPurchase callbacks to notify AdaptyUI about the process of the purchase}
The paywallController(_:didInitiatePurchase:onStartPurchase:onFinishPurchase:) event will inform you that the user has initiated a purchase. You can trigger your custom purchase flow in response to this event.
Also, remember to invoke the following callbacks to notify AdaptyUI about the process of the purchase. This is necessary for proper paywall behavior, such as showing the loader, among other things:
Callback
Description
onStartPurchase
The callback should be invoked to notify AdaptyUI that the purchase is started.
onFinishPurchase
The callback should be invoked to notify AdaptyUI that the purchase is finished.
Initialize the visual paywall you want to display by using the .paywallController(for:products:viewConfiguration:delegate:observerModeDelegate:) method:
An AdaptyPaywall object to obtain a controller for the desired paywall.
Products
optional
Provide an array of AdaptyPaywallProduct objects to optimize the display timing of products on the screen. If nil is passed, AdaptyUI will automatically fetch the necessary products.
ViewConfiguration
required
An 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.
Delegate
required
An AdaptyPaywallControllerDelegate to listen to paywall events. Refer to Handling paywall events topic for more details.
ObserverModeDelegate
required
The AdaptyObserverModeDelegate object you’ve implemented in the previous step
TagResolver
optional
Define 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.
Returns:
Object
Description
AdaptyPaywallController
An object, representing the requested paywall screen
After the object has been successfully created, you can display it like so:
In order to display the visual paywall on the device screen, use the .paywall modifier in SwiftUI:
@State var paywallPresented = falsevar body: some View { Text("Hello, AdaptyUI!") .paywall( isPresented: $paywallPresented, paywall: <paywall object>, configuration: <LocalizedViewConfiguration>, didPerformAction: { action in switch action { case .close: paywallPresented = false default: // Handle other actions break } }, didFinishRestore: { profile in /* check access level and dismiss */ }, didFailRestore: { error in /* handle the error */ }, didFailRendering: { error in paywallPresented = false }, observerModeDidInitiatePurchase: { product, onStartPurchase, onFinishPurchase in // use the product object to handle the purchase // use the onStartPurchase and onFinishPurchase callbacks to notify AdaptyUI about the process of the purchase }, )}
Request parameters:
Parameter
Presence
Description
Paywall
required
An AdaptyPaywall object to obtain a controller for the desired paywall.
Product
optional
Provide an array of AdaptyPaywallProduct objects to optimize the display timing of products on the screen. If nil is passed, AdaptyUI will automatically fetch the necessary products.
Configuration
required
An 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.
TagResolver
optional
Define 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.
Closure parameters:
Closure parameter
Description
didFinishRestore
If Adapty.restorePurchases() succeeds, this callback will be invoked.
didFailRestore
If Adapty.restorePurchases() fails, this callback will be invoked.
didFailRendering
If an error occurs during the interface rendering, this callback will be invoked.
observerModeDidInitiatePurchase
This callback is invoked when a user initiates a purchase.