Skip to content

Commit 52eadf2

Browse files
committed
Merge branch 'ADP-5877-NEW' into develop
2 parents c8d7cad + 1d79d94 commit 52eadf2

1 file changed

Lines changed: 55 additions & 50 deletions

File tree

src/content/docs/ios/migration-to-ios-sdk-v4.mdx

Lines changed: 55 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,40 @@
11
---
22
title: "Migrate Adapty iOS SDK to v. 4.0"
3-
description: "Migrate to Adapty iOS SDK v4.0 (beta) by replacing paywall builder methods with flow methods, compatible with both Paywall Builder and Flow Builder."
3+
description: "Migrate to Adapty iOS SDK v4.0 (beta) by replacing paywall APIs with flow APIs, compatible with both Paywall Builder and Flow Builder."
44
metadataTitle: "Migrating to Adapty iOS SDK v4.0 (beta) | Adapty Docs"
55
---
66

7-
Adapty iOS SDK 4.0 (beta) introduces new flow methods to replace the v3 paywall methods. The new flow methods work with both the Paywall Builder and the new Flow Builder — no setup changes are required on the Adapty Dashboard side. There are three things to know about the type changes:
7+
Adapty iOS SDK 4.0 (beta) introduces flows and renames the paywall APIs accordingly. The new APIs work with both the Paywall Builder and the new Flow Builder — no setup changes are required on the Adapty Dashboard side.
88

9-
- **`AdaptyFlow` is a new type.** It is a placement that wraps one or more paywalls — the value returned by the new `Adapty.getFlow(placementId:)` method.
10-
- **`AdaptyPaywall` has been renamed to `AdaptyFlowPaywall`.** Code that previously held a single paywall now holds an `AdaptyFlowPaywall` (the type the SDK returns inside an `AdaptyFlow.paywalls` collection or via flow-builder APIs).
9+
There are three things to know about the type changes:
10+
11+
- **`AdaptyFlow` is a new type.** It is a placement that wraps one or more paywalls — the value returned by the new `Adapty.getFlow(placementId:)` method. Code that previously held an `AdaptyPaywall` now holds an `AdaptyFlow`.
12+
- **`AdaptyPaywall` has been renamed to `AdaptyFlowPaywall`.** It exists as an item inside `AdaptyFlow.paywalls`. Typical v3 migration paths don't interact with it directly — you'll encounter it only if you build flow-aware UI by walking `flow.paywalls`.
1113
- **`AdaptyPaywallProduct` is unchanged.** Methods that returned `[AdaptyPaywallProduct]` still do — there is no `AdaptyFlowProduct`.
1214

13-
1. Replace `Adapty.getPaywall()` with `Adapty.getFlow()`.
14-
2. Replace `AdaptyUI.getPaywallConfiguration(forPaywall:)` with `AdaptyUI.getFlowConfiguration(forFlow:)`.
15-
3. Replace `AdaptyPaywallController` with `AdaptyFlowController` (UIKit).
16-
4. Replace `AdaptyPaywallControllerDelegate` with `AdaptyFlowControllerDelegate` (UIKit).
17-
5. Replace the SwiftUI `.paywall()` modifier with `.flow()`.
18-
6. Replace `AdaptyPaywallView` with `AdaptyFlowView` (SwiftUI).
19-
7. Replace `getPaywallProducts(paywall:)` with `getPaywallProducts(flow:)`.
20-
8. Update `AdaptyUICustomVideoAsset.player` to use `AVPlayer` instead of `AVQueuePlayer`.
21-
9. Update `AdaptyUIResolvedFontAsset` usage if you access font properties directly.
15+
## Quick reference
16+
17+
| v3 | v4 |
18+
|---|---|
19+
| `Adapty.getPaywall(placementId:locale:)` | `Adapty.getFlow(placementId:)` |
20+
| `AdaptyUI.getPaywallConfiguration(forPaywall:)` | `AdaptyUI.getFlowConfiguration(forFlow:locale:)` |
21+
| `Adapty.getPaywallProducts(paywall:)` | `Adapty.getPaywallProducts(flow:)` |
22+
| `AdaptyPaywallController` | `AdaptyFlowController` |
23+
| `AdaptyPaywallControllerDelegate` | `AdaptyFlowControllerDelegate` |
24+
| `AdaptyUI.paywallController(with:delegate:)` | `AdaptyUI.flowController(with:delegate:)` |
25+
| `.paywall()` (SwiftUI modifier) | `.flow()` |
26+
| `AdaptyPaywallView` | `AdaptyFlowView` |
27+
28+
## Removed APIs
29+
30+
- **`Adapty.getPaywallProductsWithoutDeterminingOffer(paywall:)`** — removed. All products now include offer information, so the separate eligibility pass is no longer needed.
31+
- **`AdaptyPaywallProductWithoutDeterminingOffer`** — removed. Callbacks that previously passed this type (such as `didSelectProduct`) now pass `AdaptyPaywallProduct`.
2232

23-
## Replace getPaywall with getFlow
33+
## Fetching paywalls
2434

25-
Replace `Adapty.getPaywall()` with `Adapty.getFlow()`. The returned type changes from `AdaptyPaywall` to `AdaptyFlow`. The `locale` parameter has moved from the fetch call to `AdaptyUI.getFlowConfiguration(forFlow:locale:)` — see the next section.
35+
### Adapty.getPaywall → Adapty.getFlow
36+
37+
The returned type changes from `AdaptyPaywall` to `AdaptyFlow`. The `locale` parameter has moved out of the fetch call — see the next section.
2638

2739
```diff showLineNumbers
2840
- let paywall = try await Adapty.getPaywall(
@@ -32,16 +44,16 @@ Replace `Adapty.getPaywall()` with `Adapty.getFlow()`. The returned type changes
3244
+ let flow = try await Adapty.getFlow(placementId: "YOUR_PLACEMENT_ID")
3345
```
3446

35-
## Replace getPaywallConfiguration with getFlowConfiguration
47+
### AdaptyUI.getPaywallConfiguration → AdaptyUI.getFlowConfiguration
3648

37-
Replace `AdaptyUI.getPaywallConfiguration(forPaywall:)` with `AdaptyUI.getFlowConfiguration(forFlow:)`. The method now takes an `AdaptyFlow` object instead of `AdaptyPaywall`. Locale handling now lives here — pass it via the `locale:` parameter:
49+
The method now takes an `AdaptyFlow` and accepts the `locale:` parameter:
3850

3951
```diff showLineNumbers
4052
- let paywallConfiguration = try await AdaptyUI.getPaywallConfiguration(forPaywall: paywall)
4153
+ let flowConfiguration = try await AdaptyUI.getFlowConfiguration(forFlow: flow)
4254
```
4355

44-
If you previously passed `locale:` to `getPaywall`, pass it to `getFlowConfiguration` instead:
56+
If you previously passed `locale:` to `getPaywall`, pass it here instead:
4557

4658
```diff showLineNumbers
4759
- let paywall = try await Adapty.getPaywall(placementId: "main", locale: "fr")
@@ -50,9 +62,20 @@ If you previously passed `locale:` to `getPaywall`, pass it to `getFlowConfigura
5062
+ let flowConfiguration = try await AdaptyUI.getFlowConfiguration(forFlow: flow, locale: "fr")
5163
```
5264

53-
## Replace AdaptyPaywallController with AdaptyFlowController (UIKit)
65+
### getPaywallProducts(paywall:) → getPaywallProducts(flow:)
66+
67+
`getPaywallProducts` now takes an `AdaptyFlow` returned by `Adapty.getFlow`:
68+
69+
```diff showLineNumbers
70+
- let products = try await Adapty.getPaywallProducts(paywall: paywall)
71+
+ let products = try await Adapty.getPaywallProducts(flow: flow)
72+
```
73+
74+
## UIKit
75+
76+
### AdaptyPaywallController → AdaptyFlowController
5477

55-
Replace `AdaptyPaywallController` with `AdaptyFlowController` and update the factory method name:
78+
Rename the controller type and the factory method:
5679

5780
```diff showLineNumbers
5881
- let controller = try AdaptyUI.paywallController(
@@ -65,9 +88,9 @@ Replace `AdaptyPaywallController` with `AdaptyFlowController` and update the fac
6588
+ )
6689
```
6790

68-
## Replace AdaptyPaywallControllerDelegate with AdaptyFlowControllerDelegate (UIKit)
91+
### AdaptyPaywallControllerDelegate AdaptyFlowControllerDelegate
6992

70-
Rename the delegate protocol and update all method signatures. Note that `didSelectProduct` now receives `AdaptyPaywallProduct` instead of `AdaptyPaywallProductWithoutDeterminingOffer` — products always include offer information in SDK 4.0 (beta).
93+
Rename the protocol and update every method signature. Note that `didSelectProduct` now receives `AdaptyPaywallProduct` instead of the removed `AdaptyPaywallProductWithoutDeterminingOffer`.
7194

7295
```diff showLineNumbers
7396
- class YourClass: AdaptyPaywallControllerDelegate {
@@ -145,9 +168,11 @@ Rename the delegate protocol and update all method signatures. Note that `didSel
145168
}
146169
```
147170

148-
## Replace SwiftUI .paywall() with .flow()
171+
## SwiftUI
172+
173+
### .paywall() modifier → .flow()
149174

150-
Rename the modifier from `.paywall()` to `.flow()` and update the configuration parameter name from `paywallConfiguration` to `flowConfiguration`:
175+
Rename the modifier and update the configuration parameter name:
151176

152177
```diff showLineNumbers
153178
@State var flowPresented = false // rename freely — the variable name is your choice
@@ -167,9 +192,9 @@ Rename the modifier from `.paywall()` to `.flow()` and update the configuration
167192
}
168193
```
169194

170-
## Replace AdaptyPaywallView with AdaptyFlowView (SwiftUI)
195+
### AdaptyPaywallView AdaptyFlowView
171196

172-
If you use `AdaptyPaywallView` directly in your SwiftUI code, rename it to `AdaptyFlowView`, update the configuration parameter, and update any `didSelectProduct` closure — it now receives `AdaptyPaywallProduct` instead of `AdaptyPaywallProductWithoutDeterminingOffer`:
197+
Rename the view, update the configuration parameter, and update any `didSelectProduct` closure — it now receives `AdaptyPaywallProduct` instead of the removed `AdaptyPaywallProductWithoutDeterminingOffer`:
173198

174199
```diff showLineNumbers
175200
- AdaptyPaywallView(
@@ -185,42 +210,22 @@ If you use `AdaptyPaywallView` directly in your SwiftUI code, rename it to `Adap
185210
)
186211
```
187212

188-
## Update getPaywallProducts call sites
213+
## AdaptyUI custom assets
189214

190-
In v4, `getPaywallProducts` has two overloads — a new `flow:` overload, and the existing `paywall:` overload (which now takes `AdaptyFlowPaywall` instead of `AdaptyPaywall`). Pick the form that matches what your code holds:
215+
### AdaptyUICustomVideoAsset.player
191216

192-
If your code holds an `AdaptyFlow` (the new placement type returned by `Adapty.getFlow`):
193-
194-
```diff showLineNumbers
195-
- let products = try await Adapty.getPaywallProducts(paywall: paywall)
196-
+ let products = try await Adapty.getPaywallProducts(flow: flow)
197-
```
198-
199-
If your code still works with a single paywall (now `AdaptyFlowPaywall`), keep the `paywall:` label — only the type changes:
200-
201-
```diff showLineNumbers
202-
- let products = try await Adapty.getPaywallProducts(paywall: paywall) // paywall: AdaptyPaywall
203-
+ let products = try await Adapty.getPaywallProducts(paywall: paywall) // paywall: AdaptyFlowPaywall
204-
```
205-
206-
The `getPaywallProductsWithoutDeterminingOffer` method has been removed. All products now include offer information directly, so a separate eligibility-checking pass is no longer needed.
207-
208-
## Update AdaptyUICustomVideoAsset.player
209-
210-
If you use custom video assets, replace `AVQueuePlayer` with `AVPlayer` when constructing the `.player(...)` case:
217+
If you use custom video assets, replace `AVQueuePlayer` with `AVPlayer`:
211218

212219
```diff showLineNumbers
213220
- case player(item: AVPlayerItem, player: AVQueuePlayer, preview: AdaptyUICustomImageAsset?)
214221
+ case player(item: AVPlayerItem, player: AVPlayer, preview: AdaptyUICustomImageAsset?)
215222
```
216223

217-
## Update AdaptyUIResolvedFontAsset
224+
### AdaptyUIResolvedFontAsset
218225

219226
`AdaptyUIResolvedFontAsset` is no longer a typealias for `UIFont`. It is now a struct. If you access the underlying font directly, use the `.font` property:
220227

221228
```diff showLineNumbers
222229
- let uiFont: UIFont = fontAsset
223230
+ let uiFont: UIFont = fontAsset.font
224231
```
225-
226-
The struct also exposes `defaultColor`, `defaultLetterSpacing`, and `defaultLineHeight` for advanced typography control.

0 commit comments

Comments
 (0)