Migrate Adapty Flutter SDK to v4.4

Adapty Flutter SDK 4.4 changes the fallback file format, requires iOS 16 for flows, and reports more flow errors to your app. To update your app from 4.3 to 4.4, set the adapty_flutter version to ^4.4.0, and replace both fallback files in the same build. Earlier SDK versions reject the new files. Then review each flow error change in this guide.

If you’re still on 4.1, start with Migrate to v4.3 and then follow this guide. An app on 4.0 needs the v4.1 changes first.

Warning

The fallback file format changed in 4.4, and the compiler can’t detect an outdated file. Without new fallback files, every placement loses its fallback.

Quick reference

v4.3v4.4
Fallback files downloaded for 4.1–4.3New fallback file format; download both files again
Flows open on iOS 15Flows require iOS 16
On iOS, AdaptyUIFlowPlatformView stays empty when its flow can’t loadIt reports the error to your flow error callbacks
On iOS, AdaptyUI() and AdaptyUIFlowView calls made while AdaptyUI isn’t activated throw errors with AdaptyErrorCode.unknownThey throw errors with adaptyUINotActivated or adaptyNotActivated
On Android, the SDK only logs flow script errorsThey reach your flow error callbacks as AdaptyErrorCode.jsException
The default close handling calls dismiss() for AdaptyUIFlowPlatformView, which throws an uncaught errorThe default close handling leaves an embedded flow on screen; remove the widget to close it

Installation

Update adapty_flutter to v4.4 in your pubspec.yaml:

dependencies:
  adapty_flutter: ^4.4.0

If your app uses Kids Mode, specify adapty_flutter_kids instead:

dependencies:
  adapty_flutter_kids: ^4.4.0

The requirements are unchanged from 4.3: Flutter 3.32.0 (Dart 3.8.0) and iOS 15.0. Flows are the exception: see Flows require iOS 16. See Install Adapty SDK for the full setup.

Replace the fallback files

To download the fallback files again, in Placements, click Fallbacks > Download iOS Fallback. In the Adapty SDK v4.4.0 and higher row, click Download. Repeat with Download Android Fallback.

The downloaded files are named ios_4_4_0_fallback.json and android_4_4_0_fallback.json. Move them to the assets folder of your project, in place of the outdated files. Give each file the name that your app passes to Adapty().setFallback, or update the names in that call.

With an outdated file, Adapty().setFallback throws an AdaptyError. To verify the new files, run the app on iOS and on Android, and make sure that this call throws no error.

Flows require iOS 16

Starting from 4.4, flows require iOS 16 or later. On iOS 15, AdaptyUI().createFlowView() throws an AdaptyError with AdaptyErrorCode.platformNotSupported, and AdaptyUIFlowPlatformView stays empty and reports the same error. Onboardings and the rest of the SDK still support iOS 15.

When your app receives this error, show your own content instead, such as a custom paywall.

Flow load errors reach your callbacks on iOS

On iOS, the onDidReceiveError callback of AdaptyUIFlowPlatformView receives an error when the widget can’t show the flow. The flowViewDidReceiveError method of your flows events observer receives the same error. Each time your app creates the widget, it reports the error once. Before 4.4, the widget stayed empty. On Android, the widget still reports nothing when its flow fails to load. The widget reports the following errors:

  • On iOS 15: AdaptyErrorCode.platformNotSupported.
  • On iOS 16 and later, when the flow fails to load: the error that AdaptyUI().createFlowView() throws for that flow. For example, the flow fails to load while AdaptyUI isn’t activated, or for a customLayoutId that the flow doesn’t have.

Your flow error handling, such as closing the screen, now runs in these cases too. AdaptyUIFlowView.dismiss() fails for the view of this widget, so if your flowViewDidReceiveError calls it, catch its error, as in View errors. Remove the widget, and show your own content. To retry a temporary failure, such as AdaptyErrorCode.networkFailed, build the widget again under a new Key.

AdaptyUI errors have new codes on iOS

On iOS, an AdaptyUI() or AdaptyUIFlowView call throws an error with a new code when AdaptyUI isn’t activated: before Adapty().activate() completes, or after activation with withActivateUI(false). What your app requests determines the code:

  • A flow view: AdaptyErrorCode.adaptyUINotActivated.
  • An onboarding: AdaptyErrorCode.adaptyNotActivated.

Before 4.4, these errors had AdaptyErrorCode.unknown. If your code handles unknown for them, handle the new codes too. For AdaptyErrorCode.platformNotSupported, read Flows require iOS 16.

Flow script errors reach your callbacks on Android

On Android, the flow script can throw an exception while it handles an SDK event. Starting from 4.4, this exception reaches flowViewDidReceiveError and the onDidReceiveError callback of AdaptyUIFlowPlatformView as AdaptyErrorCode.jsException, the same as on iOS. Before, the SDK only logged it.

If your app doesn’t set a flows events observer, a flow from AdaptyUI().createFlowView() closes on this error. To keep the flow open, set an observer with AdaptyUI().setFlowsEventsObserver(), and handle the error there.

Close embedded flows by removing the widget

Starting from 4.4, the default close handling doesn’t call dismiss() for a flow embedded with AdaptyUIFlowPlatformView. Before 4.4, this call always failed, with an uncaught AdaptyErrorCode.wrongParam error. To close an embedded flow, remove its widget when it receives CloseAction, and on Android, AndroidSystemBackAction.

When the default handling of a flow event fails, such as a dismissal or the opening of a URL, the SDK now writes the error to its log. Before 4.4, the SDK threw an uncaught error. If your crash reporter recorded these errors, they no longer reach it.