Support new and old Adapty SDKs with a single flow

Flows need Adapty SDK 4.0 or later, but some flow features need a later Adapty SDK version. For each feature, the docs state the version it needs and what users with an earlier version see. For example, the prod_billing_price variable shows the monthly payment of a 12-month commitment plan with Adapty iOS SDK 4.3.1 or later. With Adapty iOS SDK 4.3.0, it shows the yearly total.

Your users don’t all update the app at once, so some of them run app builds with an earlier Adapty SDK version. To decide what these users see in place of a new feature, add an SDK version condition to the flow. The condition compares the Adapty SDK version of the app build with the version you enter. With an SDK version condition, you can:

  • Send users to a screen for their SDK version.
  • Show or hide an element by SDK version.
  • Show different messages in the same text element based on the SDK version.
  • Change an element’s appearance or disable it based on the SDK version.

Your metrics and A/B tests stay intact. You don’t need to copy the flow or split your user traffic across multiple flows with audiences.

How the SDK version condition works

In the Flow & Paywall Builder, sdk.version is a system variable that holds the Adapty SDK version of the app build that displays the flow. The Adapty SDK reports this version, so your app code doesn’t pass it. An SDK version condition compares sdk.version with the version that you enter. The system variable is available only in these condition editors.

In each editor, click the Variable field, open the System tab, and select sdk.version. If the flow declares a custom variable with the ID sdk.version, that variable keeps its value and behavior. The System tab omits the SDK version variable for that flow.

Choose one of the two SDK version comparisons.

ComparisonMatches an app build withUse it for
This version and above (≥)The version in the condition, or a later versionThe main screen or element, which has the new feature
Below this version (<)A version earlier than the version in the conditionThe backward-compatible screen or element, without the new feature

If the flow can’t read the Adapty SDK version of the app build, it treats the version as earlier than any version in a condition. So Below this version matches, and This version and above doesn’t.

Choose the version to enter

Find the feature’s minimum Adapty SDK version in its documentation. Enter the corresponding native SDK version in the Value field. If the feature requires a specific patch, enter it in full, such as 4.3.2. If you leave out the patch, the condition uses zero. For example, 4.4 means 4.4.0.

The condition compares the Adapty iOS SDK version on iOS and the core library version io.adapty:android-sdk on Android. The Android bill of materials (BOM) io.adapty:adapty-bom can have a different version. For example, Android BOM 4.4.2 includes core 4.4.0. That build matches This version and above with 4.4 and Below this version with 4.4.1.

React Native, Flutter, Unity, Kotlin Multiplatform, and Capacitor report the native Adapty SDK version they include. To find the core version on Android, look up the resolved io.adapty:android-sdk dependency in your app. If a feature requires different native versions on iOS and Android, combine the SDK version condition with a platform condition for each threshold.

The Value field accepts major.minor or major.minor.patch. You can also select a version from the list. The list shows the Adapty SDK versions that flow features need, newest first, and marks the first one Latest.

Correct an invalid version

The condition shows an error if the version is missing or invalid, such as 4.x. If publishing fails with Invalid SDK version condition, open Details in the error notification. Use the link or the reported location to find the condition, then enter a valid version and publish again. If the flow has a published version, users continue to get that version until you publish successfully. See Common issues.

Show a screen by Adapty SDK version

The flow always opens on its first screen, so you can’t show a backward-compatible screen in place of the first screen. Put a conditional action on a screen that all users see before the main screen, such as a welcome screen. If the new feature is on the first screen of the flow, show an element by Adapty SDK version instead.

  1. Set up the main screen, with the new feature.
  2. To create the backward-compatible screen, duplicate the main screen, and remove the new feature from the copy. The backward-compatible copy will keep the actions of the main screen, but not the element with a higher version requirement. To tell the two screens apart in navigation and in flow metrics, give them distinct names.
  3. On the main screen, replace each Navigate Next action with Navigate to Screen, and select specific screens for Destination. The copy will appear right after the main screen, so Navigate Next on the main screen would open the backward-compatible copy.
  4. On the screen before the main screen, select the element that moves users forward, such as the Continue button.
  5. In the Interactions panel, set its action to Conditional Action.
  6. In the if block, click the Variable field, open the System tab, and select sdk.version. Keep ≥ (This version and above), and enter the version from Choose the version to enter, such as 4.4.
  7. In the then block, add Navigate to Screen with the main screen.
  8. In the else block, add Navigate to Screen with the backward-compatible screen.

If several elements lead to the main screen, such as a Continue button and the options of a quiz, set up the conditional action on each of them.

If the screens after the main screen also have the new feature, make a backward-compatible copy of each of them. On each backward-compatible copy except the last, set the Destination of Navigate to Screen to the next backward-compatible copy.

If users with an earlier version don’t need the main screen, don’t make a backward-compatible screen. In the else block, add Navigate to Screen with the screen after the main screen.

A backward-compatible screen adds to the size of the flow, and later edits to the main screen don’t reach it. To change only part of a screen, show an element by Adapty SDK version instead.

Show an element by Adapty SDK version

To replace one element instead of a whole screen, put two elements on the screen: the main element, with the new feature, and the backward-compatible element, without it. Enter the same version in the conditions of both elements, so that each user sees one of the two.

  1. Select the main element. In the Visibility section of the right panel, select Conditional.
  2. Click the Variable field, open the System tab, and select sdk.version. Keep ≥ (This version and above), and enter the version from Choose the version to enter, such as 4.4.
  3. Select the backward-compatible element. In the Visibility section, select Conditional.
  4. Click the Variable field, open the System tab, and select sdk.version. Click ≥, select Below this version, and enter the same version as in step 2.

If users with an earlier version don’t need a backward-compatible element, do only steps 1 and 2.

A Show element or Hide element action on the main element or the backward-compatible element overrides the SDK version condition of that element.

You can combine the SDK version condition with other conditions, such as the platform of the device. The selector above the conditions requires all of them to match, or any one of them. If you add a condition to the main element, give the backward-compatible element the opposite condition, so that each user still sees one of the two. For example, to show the main element only on iOS:

  • Main element: Set the selector to all, and add sdk.version This version and above 4.4 and system.platform = iOS.
  • Backward-compatible element: Set the selector to any, and add sdk.version Below this version 4.4 and system.platform = Android.
Note

A visibility condition determines what appears after the SDK decodes the flow. A custom element has its own format guard. On SDK versions earlier than 4.4, that guard supplies the fallback content in place of the native view.

If you set the custom element’s visibility to sdk.version This version and above 4.4, the flow opens on iOS 4.3.2 with both the custom element and its fallback hidden. To show the fallback on earlier SDK versions, leave the custom element’s visibility unconditional and edit its fallback content.

Change text or an element state by Adapty SDK version

  • In conditional text, add a condition with sdk.version This version and above 4.4. Enter “Try the new widget” under then and “Update the app for new features” under else.
  • On a Buy button, add a custom state named Modern. Use sdk.version This version and above 4.4 as its condition. Give the state a different background color.
  • On an Open widget button, add the Disabled state with sdk.version Below this version 4.4. The button responds to taps on version 4.4 or later.

A condition that depends only on the SDK version has the same result for the whole flow session. When the Modern condition matches, it takes priority over the Selected, Invalid, Active (focused), and Disabled styles, so the button doesn’t show those styles in that session. A matching Disabled condition still stops the element from responding to taps. See element state priority.

Test the SDK version condition

The canvas and web preview use the Latest major and minor version from the value list for conditional visibility and text. A threshold with the same major and minor counts as a match for This version and above, even if it specifies a patch. To select a hidden element, click it in the Layers panel. To preview an element state on the canvas, select its tab in States. The canvas shows that state regardless of its condition. To test conditional actions, open the flow in your app.

When you publish a flow, the users of every placement that serves it get the new version on their next request to that placement. To test the condition before real users get it:

  1. Add the flow to a placement that your test build requests and your released app doesn’t. If the flow already serves a placement of your released app, test a copy of the flow instead.
  2. Register the device as a test device, so that it gets the latest published version of the flow instead of a cached one.
  3. Publish the flow, and open it in a build with the version in the conditions or later. The build should show the main screen or element.
  4. To see the backward-compatible screen or element in the same build, change the version in the conditions to a version above the Adapty SDK version of the build, such as 9.0. Then publish the flow, and open it again.
  5. Enter the original version in the conditions again, and publish the flow.

The preview in the Adapty mobile app doesn’t read the Adapty SDK version of your app, so it can show a different screen or element than your app shows.

Limitations

  • The condition can’t tell which framework the app uses: An SDK version condition compares only the version of the native Adapty SDK. Some features also depend on the framework of the app. For example, on Android, elements outside the sheet of a hero screen respond to taps only in native Android and React Native apps. A Flutter app with the same native Adapty SDK version matches This version and above too. Before you add a condition for a feature, see which apps its docs list.
  • First-frame appearance on Adapty iOS SDK 4.0 and 4.1: An element hidden by a visibility condition can appear for one frame as its screen opens. On the first screen, default text or the Default state can also appear for one frame before the condition’s result appears. To keep a version-specific element off a screen that these users open, send them to a backward-compatible screen.