To enable in-app purchases, you need to understand three key concepts:
Products – anything users can buy (subscriptions, consumables, lifetime access)
Flows – screen sequences that present products to users, built in the no-code Flow Builder. The SDK retrieves them via getFlow. If you’d rather build the UI in your own code, use a paywall instead — see Implement paywalls manually.
Placements – where and when you show flows in your app (like main, onboarding, settings). You attach flows to placements in the dashboard, then request them by placement ID in your code. This makes it easy to run A/B tests and show different flows to different users.
Adapty offers you three ways to enable purchases in your app. Select one of them depending on your app requirements:
You implement your paywall UI in your app code, but still get the flow object from Adapty to maintain flexibility in product offerings. See the guide.
Observer mode
🔴 Hard
You already have your own purchase handling infrastructure and want to keep using it. Note that the observer mode has its limitations in Adapty. See the article.
The steps below show how to implement a flow created in the Adapty Flow Builder.
To display a flow created in the Adapty Flow Builder, in your app code, you only need to:
Get the flow: Get it from Adapty.
Display it and Adapty will handle purchases for you: Show the view in your app.
Handle button actions: Associate user interactions with your app’s response to them. For example, open links or close the flow when users click buttons.
Your flows are associated with placements configured in the dashboard. Placements allow you to run different flows for different audiences or to run A/B tests.
To get a flow created in the Adapty Flow Builder, you need to:
Get the flow object by the placement ID using the getFlow method and check whether it has a view configuration.
Get the view configuration using the getFlowConfiguration method. It contains the UI elements and styling needed to display the flow.
Now, when you have the flow configuration, it’s enough to add a few lines to display your flow.
In SwiftUI, when displaying the flow, you also need to handle events. didFailPurchase, didFinishRestore, didFailRestore, and didReceiveError are required. When testing, you can just copy the code from the snippet below to log these events.
Handling didFinishPurchase isn’t required, but is useful when you want to perform actions after a successful purchase. If you don’t implement that callback, the flow will dismiss automatically.
Implement AdaptyFlowControllerDelegate to handle events. At minimum, implement the required error handlers (the three methods that have no default implementation):
For more details on how to display a flow, see our guide.
3. Handle button actions
When users click buttons, the iOS SDK automatically handles purchases, restoration, closing the flow, and opening links.
However, other buttons have custom or pre-defined IDs and require handling actions in your code. Or, you may want to override their default behavior.
For example, here is how to handle the close button. In UIKit, the SDK dismisses the controller automatically when .close fires — override only if you want custom behavior. In SwiftUI, you must set your isPresented binding to false yourself.
Read our guides on how to handle button actions and events.
.flow( isPresented: $flowPresented, flowConfiguration: flowConfiguration, didPerformAction: { action in switch action { case .close: flowPresented = false // dismiss the flow when the user taps close default: break } }, 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 })
Have questions or running into issues? Check out our support forum where you can find answers to common questions or ask your own. Our team and community are here to help!