Get onboardings in iOS SDK
After you designed the visual part for your onboarding with the builder in the Adapty Dashboard, you can display it in your iOS app. The first step in this process is to get the onboarding associated with the placement and its view configuration as described below.
Before you start, ensure that:
- You have installed Adapty iOS SDK version 3.8.0 or higher.
- You have created an onboarding.
- You have added the onboarding to a placement.
Fetch onboarding
When you create an onboarding with our no-code builder, it's stored as a container with configuration that your app needs to fetch and display. This container manages the entire experience - what content appears, how it's presented, and how user interactions (like quiz answers or form inputs) are processed. The container also automatically tracks analytics events, so you don't need to implement separate view tracking.
For best performance, fetch the onboarding configuration early to give images enough time to download before showing to users.
To get an onboarding, use the getOnboarding
method:
do {
let onboarding = try await Adapty.getOnboarding(placementId: "YOUR_PLACEMENT_ID")
// the requested onboarding
} catch {
// handle the error
}
Parameters:
Parameter | Presence | Description |
---|---|---|
placementId | required | The identifier of the desired Placement. This is the value you specified when creating a placement in the Adapty Dashboard. |
locale | optional default: | The identifier of the onboarding localization. This parameter is expected to be a language code composed of one or two subtags separated by the minus (-) character. The first subtag is for the language, the second one is for the region. Example: See Localizations and locale codes for more information on locale codes and how we recommend using them. |
fetchPolicy | default: .reloadRevalidatingCacheData | By default, SDK will try to load data from the server and will return cached data in case of failure. We recommend this option because it ensures your users always get the most up-to-date data. However, if you believe your users deal with unstable internet, consider using Note that the cache remains intact upon restarting the app and is only cleared when the app is reinstalled or through manual cleanup. Adapty SDK stores onboardings locally in two layers: regularly updated cache described above and fallback onboardings. We also use CDN to fetch onboardings faster and a stand-alone fallback server in case the CDN is unreachable. This system is designed to make sure you always get the latest version of your onboardings while ensuring reliability even in cases where internet connection is scarce. |
loadTimeout | default: 5 sec | This value limits the timeout for this method. If the timeout is reached, cached data or local fallback will be returned. Note that in rare cases this method can timeout slightly later than specified in |
Response parameters:
Parameter | Description |
---|---|
Onboarding | An AdaptyOnboarding object with: the onboarding identifier and configuration, remote config, and several other properties. |
Speed up onboarding fetching with default audience onboarding
Typically, onboardings are fetched almost instantly, so you don't need to worry about speeding up this process. However, in cases where you have numerous audiences and onboardings, and your users have a weak internet connection, fetching a onboarding may take longer than you'd like. In such situations, you might want to display a default onboarding to ensure a smooth user experience rather than showing no onboarding at all.
To address this, you can use the getOnboardingForDefaultAudience
method, which fetches the onboarding of the specified placement for the All Users audience. However, it's crucial to understand that the recommended approach is to fetch the onboarding by the getOnboarding
method, as detailed in the Fetch Onboarding section above.
Consider using getOnboarding
instead of getOnboardingForDefaultAudience
, as the latter has important limitations:
- Compatibility issues: May create problems when supporting multiple app versions, requiring either backward-compatible designs or accepting that older versions might display incorrectly.
- No personalization: Only shows content for the "All Users" audience, removing targeting based on country, attribution, or custom attributes.
If faster fetching outweighs these drawbacks for your use case, use getOnboardingForDefaultAudience
as shown below. Otherwise, use getOnboarding
as described above.
Adapty.getOnboardingForDefaultAudience(placementId: "YOUR_PLACEMENT_ID") { result in
switch result {
case let .success(onboarding):
// the requested onboarding
case let .failure(error):
// handle the error
}
}
Parameters:
Parameter | Presence | Description |
---|---|---|
placementId | required | The identifier of the desired Placement. This is the value you specified when creating a placement in the Adapty Dashboard. |
locale | optional default: | The identifier of the onboarding localization. This parameter is expected to be a language code composed of one or two subtags separated by the minus (-) character. The first subtag is for the language, the second one is for the region. Example: See Localizations and locale codes for more information on locale codes and how we recommend using them. |
fetchPolicy | default: .reloadRevalidatingCacheData | By default, SDK will try to load data from the server and will return cached data in case of failure. We recommend this option because it ensures your users always get the most up-to-date data. However, if you believe your users deal with unstable internet, consider using Note that the cache remains intact upon restarting the app and is only cleared when the app is reinstalled or through manual cleanup. Adapty SDK stores onboardings locally in two layers: regularly updated cache described above and fallback onboardings. We also use CDN to fetch onboardings faster and a stand-alone fallback server in case the CDN is unreachable. This system is designed to make sure you always get the latest version of your onboardings while ensuring reliability even in cases where internet connection is scarce. |