Flutter - Adapty SDK Installation and configuration

Learn how to install and configure Adapty SDK and AdaptyUI SDK for Flutter, essential for seamless integration of Adapty into your mobile app

Adapty comprises two crucial SDKs for seamless integration into your mobile app:

  • General AdaptySDK: This is a fundamental, mandatory SDK necessary for the proper functioning of Adapty within your app.
  • AdaptyUI SDK: This optional SDK becomes necessary if you intend to use the Adapty Paywall builder. The Paywall builder serves as a convenient, user-friendly tool tailored for a no-code approach. It empowers you with the ability to effortlessly construct a subscription purchase page, referred to as a Paywall in Adapty. This approach ensures you get the paywalls directly in your iOS or Android apps as native layout pages.
    The Adapty Paywall builder is created to set the core conversion-driving elements of paywalls with several clicks in the dashboard without spending time on minor design amendments and technical settings. It helps also to edit your paywall native layout on the fly by changing it visually in the Adapty web interface.

Please consult the compatibility table below to choose the correct pair of Adapty SDK and AdaptyUI SDK.

Adapty SDK versionAdaptyUI SDK version
2.9.32.1.0
2.10.0 or later2.1.1

❗️

Go through release checklist before releasing your app

Before releasing your application, make sure to carefully review the Release Checklist thoroughly. This checklist ensures that you've completed all necessary steps and provides criteria for evaluating the success of your integration.

Install Adapty SDKs

  1. Add Adapty and AdaptyUI to your pubspec.yaml file:

    dependencies:
    adapty_flutter: ^2.10.1
    adapty_ui_flutter: ^2.1.1
    
  2. Run:

    flutter pub get
    
  3. Import Adapty SDKs in your application in the following way:

    import 'package:adapty_flutter/adapty_flutter.dart';
    import 'package:adapty_ui_flutter/adapty_ui_flutter.dart';
    

Configure Adapty SDKs

The configuration of the Adapty SDK for Flutter slightly differs depending on the mobile operating system (iOS or Android) you are going to release it for.

Configure Adapty SDKs for iOS

Create Adapty-Info.plist and add it to your project. Add the flag AdaptyPublicSdkKey in this file with the value of your Public SDK key.

<dict>
    <key>AdaptyPublicSdkKey</key>
    <string>PUBLIC_SDK_KEY</string>
    <key>AdaptyObserverMode</key>
    <false/>
</dict>

Parameters:

ParameterPresenceDescription
AdaptyPublicSdkKeyrequiredThe key you can find in the Public SDK key field of your app settings in Adapty: App settings-> General tab -> API keys subsection
AdaptyObserverModeoptionalA boolean value controlling Observer mode. Turn it on if you handle purchases and subscription status yourself and use Adapty for sending subscription events and analytics. At any purchase or restore in your application, you'll need to call .restorePurchases() method to record the action in Adapty. The default value is false.

🚧 When running in Observer mode, Adapty SDK won't close any transactions, so make sure you're handling it.
idfaCollectionDisabledoptionalA boolean parameter, that allows you to disable IDFA collection for your iOS app. The default value is false.
For more details, refer to the Analytics integration section.

Configure Adapty SDKs for Android

  1. Add the AdaptyPublicSdkKey flag into the app’s AndroidManifest.xml (Android) file with the value of your Public SDK key.

    <application ...>
        ...
        <meta-data
               android:name="AdaptyPublicSdkKey"
               android:value="PUBLIC_SDK_KEY" />
      	<meta-data
               android:name="AdaptyObserverMode"
               android:value="false" />
    </application>
    

    Required parameters:

    ParameterPresenceDescription
    PUBLIC_SDK_KEYrequiredContents of the Public SDK key field in the App Settings -> General tab in the Adapty Dashboard. SDK keys are unique for every app, so if you have multiple apps make sure you choose the right one.
    Make sure you use the Public SDK key for Adapty initialization, since the Secret key should be used for server-side API only.
    AdaptyObserverModeoptionalA boolean value that is controlling Observer mode . Turn it on if you handle purchases and subscription status yourself and use Adapty for sending subscription events and analytics.
    The default value is false.

    🚧 When running in Observer mode, Adapty SDK won't close any transactions, so make sure you're handling it.
    AdaptyIDFACollectionDisabledoptionalA boolean parameter, that allows you to disable IDFA collection for your app. The default value is false.
    For more details, refer to the Analytics integration section.

  2. In your application, add:

    import 'package:adapty_flutter/adapty_flutter.dart';
    
  3. Activate Adapty SDK with the following code:

    try {
    	Adapty().activate();
    } on AdaptyError catch (adaptyError) {}
    } catch (e) {}
    

Set up the logging system

Adapty logs errors and other crucial information to provide insight into your app's functionality. There are the following available levels:

LevelDescription
errorOnly errors will be logged.
warnErrors and messages from the SDK that do not cause critical errors, but are worth paying attention to will be logged.
infoErrors, warnings, and serious information messages, such as those that log the lifecycle of various modules will be logged.
verboseAny additional information that may be useful during debugging, such as function calls, API queries, etc. will be logged.

You can set logLevel in your app before configuring Adapty.

try {
	await Adapty().setLogLevel(AdaptyLogLevel.verbose);
} on AdaptyError catch (adaptyError) {
} catch (e) {}

❗️

Read checklist before releasing the app

Before releasing your application, go through the Release Checklist to ensure that you have completed all the steps, and also check the success of the integration using the criteria for assessing its success.