Skip to main content

Install & configure Unity SDK

Adapty SDK includes two key modules for seamless integration into your Unity app:

  • Core Adapty: This essential SDK is required for Adapty to function properly in your app.
  • AdaptyUI: This optional module is needed if you use the Adapty Paywall Builder, a user-friendly, no-code tool for easily creating cross-platform paywalls.
tip

Want to see a real-world example of how Adapty SDK is integrated into a mobile app? Check out our sample app, which demonstrates the full setup, including displaying paywalls, making purchases, and other basic functionality.

Requirements

Adapty SDK supports iOS 13.0+, but requires iOS 15.0+ to work with paywalls created in the paywall builder.

info

Adapty supports Google Play Billing Library up to 7.x. Support for Billing Library 8.0.0 (released 30 June, 2025) is planned.

Install Adapty SDK

Release

  1. Download the adapty-unity-plugin-*.unitypackage from GitHub and import it into your project.
  1. Download and import the External Dependency Manager plugin.

  2. The SDK uses the "External Dependency Manager" plugin to handle iOS Cocoapods dependencies and Android gradle dependencies. After the installation, you may need to invoke the dependency manager:

    Assets -> External Dependency Manager -> Android Resolver -> Force Resolve

    and

    Assets -> External Dependency Manager -> iOS Resolver -> Install Cocoapods

  3. When building your Unity project for iOS, you would get Unity-iPhone.xcworkspace file, which you have to open instead of Unity-iPhone.xcodeproj, otherwise, Cocoapods dependencies won't be used.

Activate Adapty module of Adapty SDK

C#
using UnityEngine;
using AdaptySDK;

public class AdaptyListener : MonoBehaviour, AdaptyEventListener {
void Start() {
DontDestroyOnLoad(this.gameObject);
Adapty.SetEventListener(this);

var builder = new AdaptyConfiguration.Builder("YOUR_PUBLIC_SDK_KEY");

Adapty.Activate(builder.Build(), (error) => {
if (error != null) {
// handle the error
return;
}
});
}
}

To get your Public SDK Key:

  1. Go to Adapty Dashboard and navigate to App settings → General.
  2. From the Api keys section, copy the Public SDK Key (NOT the Secret Key).
  3. Replace "YOUR_PUBLIC_SDK_KEY" in the code.
important
  • Make sure you use the Public SDK key for Adapty initialization, the Secret key should be used for server-side API only.
  • SDK keys are unique for every app, so if you have multiple apps make sure you choose the right one.

Set up event listening

Create a script to listen to Adapty events. Name it AdaptyListener in your scene. We suggest using the DontDestroyOnLoad method for this object to ensure it persists throughout the application's lifespan.

Adapty uses AdaptySDK namespace. At the top of your script files that use the Adapty SDK, you may add:

C#
using AdaptySDK;

Subscribe to Adapty events:

C#
using UnityEngine;
using AdaptySDK;

public class AdaptyListener : MonoBehaviour, AdaptyEventListener {
public void OnLoadLatestProfile(Adapty.Profile profile) {
// handle updated profile data
}
}

We recommend adjusting the Script Execution Order to place the AdaptyListener before Default Time. This ensures that Adapty initializes as early as possible.

Add Kotlin Plugin to your project

warning

This step is required. If you skip it, your mobile app can crash when the paywall is displayed.

  1. In Player Settings, ensure that the Custom Launcher Gradle Template and Custom Base Gradle Template options are selected.

  2. Add the following line to /Assets/Plugins/Android/launcherTemplate.gradle:

    apply plugin: 'com.android.application'
    apply plugin: 'kotlin-android'
    apply from: 'setupSymbols.gradle'
    apply from: '../shared/keepUnitySymbols.gradle'
  3. Add the following line to /Assets/Plugins/Android/baseProjectTemplate.gradle:

    plugins {
    // If you are changing the Android Gradle Plugin version, make sure it is compatible with the Gradle version preinstalled with Unity
    // See which Gradle version is preinstalled with Unity here https://docs.unity3d.com/Manual/android-gradle-overview.html
    // See official Gradle and Android Gradle Plugin compatibility table here https://developer.android.com/studio/releases/gradle-plugin#updating-gradle
    // To specify a custom Gradle version in Unity, go do "Preferences > External Tools", uncheck "Gradle Installed with Unity (recommended)" and specify a path to a custom Gradle version
    id 'com.android.application' version '8.3.0' apply false
    id 'com.android.library' version '8.3.0' apply false
    id 'org.jetbrains.kotlin.android' version '1.8.0' apply false
    **BUILD_SCRIPT_DEPS**
    }

Please keep in mind that for paywalls and products to be displayed in your mobile application, and for analytics to work, you need to display the paywalls and, if you're using paywalls not created with the Paywall Builder, handle the purchase process within your app.

Activate AdaptyUI module of Adapty SDK

If you plan to use Paywall Builder and have installed AdaptyUI module, you need AdaptyUI to be active. You can activate it during the configuration:

C#
var builder = new AdaptyConfiguration.Builder("YOUR_PUBLIC_SDK_KEY")
.SetActivateUI(true);

Optional setup

Logging

Set up the logging system

Adapty logs errors and other important information to help you understand what is going on. There are the following levels available:

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 various information messages 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 the log level in your app during Adapty configuration:

C#
// 'verbose' is recommended for development and the first production release
var builder = new AdaptyConfiguration.Builder("YOUR_PUBLIC_SDK_KEY")
.SetLogLevel(AdaptyLogLevel.Verbose);

Data policies

Adapty doesn't store personal data of your users unless you explicitly send it, but you can implement additional data security policies to comply with the store or country guidelines.

Disable IP address collection and sharing

When activating the Adapty module, set SetIPAddressCollectionDisabled to true to disable user IP address collection and sharing. The default value is false.

Use this parameter to enhance user privacy, comply with regional data protection regulations (like GDPR or CCPA), or reduce unnecessary data collection when IP-based features aren't required for your app.

C#
var builder = new AdaptyConfiguration.Builder("YOUR_PUBLIC_SDK_KEY")
.SetIPAddressCollectionDisabled(true);

Disable advertising ID collection and sharing

When activating the Adapty module, set SetAppleIDFACollectionDisabled and/or SetGoogleAdvertisingIdCollectionDisabled to true to disable the collection of advertising identifiers. The default value is false.

Use this parameter to comply with App Store/Google Play policies, avoid triggering the App Tracking Transparency prompt, or if your app does not require advertising attribution or analytics based on advertising IDs.

C#
var builder = new AdaptyConfiguration.Builder("YOUR_PUBLIC_SDK_KEY")
.SetAppleIDFACollectionDisabled(true);
.SetGoogleAdvertisingIdCollectionDisabled(true);

Set up media cache configuration for AdaptyUI

By default, AdaptyUI caches media (such as images and videos) to improve performance and reduce network usage. You can customize the cache settings by providing a custom configuration.

Use SetAdaptyUIMediaCache to override the default cache settings:

C#
var builder = new AdaptyConfiguration.Builder("YOUR_PUBLIC_SDK_KEY")
.SetAdaptyUIMediaCache(
100 * 1024 * 1024, // MemoryStorageTotalCostLimit 100MB
null, // MemoryStorageCountLimit
100 * 1024 * 1024 // DiskStorageSizeLimit 100MB
);

Parameters:

ParameterRequiredDescription
memoryStorageTotalCostLimitoptionalTotal cache size in memory in bytes. Defaults to platform-specific value.
memoryStorageCountLimitoptionalThe item count limit of the memory storage. Defaults to platform-specific value.
diskStorageSizeLimitoptionalThe file size limit on disk in bytes. Defaults to platform-specific value.