Capacitor - Adapty SDK installation & configuration

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

  • Core Adapty: This module is required for Adapty to function properly in your app.
  • AdaptyUI: This module renders flows, in addition to old builder paywalls. AdaptyUI is automatically activated along with the core module.
Tip

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

Requirements

The Adapty Capacitor SDK has the following version requirements:

Adapty SDK VersionCapacitor VersioniOS Version
4.4+816.0+ for flows, 15.0+ for other features
4.1–4.3815.0+
3.16.0+815.0+
3.15714.0+

Capacitor versions 6 and below are not supported.

Building for iOS requires Xcode 26 or later — the native iOS SDK is built with Swift tools 6.2. On Android, the minimum SDK is 24.

Info

Installing the SDK is step 5 of the Adapty setup. Before purchases work in your app, you also need to connect your app to the stores, then create products, a paywall, and a placement in the Adapty Dashboard. The quickstart guide walks through all required steps.

Dependencies

Adapty SDK works with these Google Play Billing Library versions on Android:

Adapty SDK versionBilling Library version
3.17.0 and laterv8
3.15.0–3.16.3v7 by default, v8 if another dependency raises it
Note

Compatibility with a Billing Library version doesn’t mean Adapty supports every feature Google introduced in it. Before you adopt a new Google Play billing capability, see Product in Play Store.

Install Adapty SDK

Release

We always recommend installing the latest available version of the SDK — it includes the newest stability fixes and improvements.

Install Adapty SDK:

npm install @adapty/capacitor
npx cap sync

Set up your iOS project

On iOS, the SDK installs the native Adapty SDKs (Adapty, AdaptyUI, AdaptyPlugin) through the package manager of your app’s iOS project:

  • Swift Package Manager (recommended): Capacitor 8 creates new iOS projects with SPM by default, and the SDK needs no extra setup.
  • CocoaPods (SDK 4.2.0 and later): Your Podfile installs the native SDKs as pods from Adapty’s spec repo, not from the public CocoaPods spec repo, which goes read-only in December 2026. SDK 4.0 and 4.1 don’t support CocoaPods.
  • For new apps, add the iOS platform with the SPM package manager:

    npx cap add ios --packagemanager SPM
  • For existing apps on CocoaPods, migrate the iOS project to SPM by following Capacitor’s guide to using SPM in an existing project, or keep CocoaPods and follow the CocoaPods tab.

Upgrading from v3? See Migrate Adapty Capacitor SDK to v4.1 for the full list of API changes.

Activate Adapty module of Adapty SDK

Note

The Adapty SDK only needs to be activated once in your app.

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.

Or, get it programmatically, using the Adapty CLI:

npm install -g adapty
adapty auth login
adapty apps list

Or, directly :

npx adapty auth login
adapty apps list
  • 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.

Copy the following code to any app file to activate Adapty:

import { adapty } from '@adapty/capacitor';

try {
  await adapty.activate({
    apiKey: 'YOUR_PUBLIC_SDK_KEY',
    params: {
      // verbose logging is recommended for the development purposes and for the first production release
        logLevel: 'verbose',
      // in the development environment, use this variable to avoid multiple activation errors. Set it to your development environment variable
      __ignoreActivationOnFastRefresh: true,
    }
  });
  console.log('Adapty activated successfully!');
} catch (error) {
  console.error('Failed to activate Adapty SDK:', error);
}
Important

Wait for activate to resolve before calling any other Adapty SDK method. See Call order in Capacitor SDK for the full sequence.

Tip

To avoid activation errors in the development environment, use the tips.

Now set up paywalls in your app:

Activate AdaptyUI module of Adapty SDK

If you plan to use the Flow & Paywall Builder, you need the AdaptyUI module. It is done automatically when you activate the core module; you don’t need to do anything else.

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
debugEverything above, plus low-level internal details of the native SDK. Android has no separate level for it and logs at verbose. Available starting from SDK version 4.3.0

You can set the log level in your app before or during Adapty configuration:

// Set log level before activation
adapty.setLogLevel({ logLevel: 'verbose' });

// Or set it during configuration
await adapty.activate({
  apiKey: 'YOUR_PUBLIC_SDK_KEY',
  params: {
    logLevel: '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 ipAddressCollectionDisabled 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.

await adapty.activate({
  apiKey: 'YOUR_PUBLIC_SDK_KEY',
  params: {
    ipAddressCollectionDisabled: true,
  }
});

Disable advertising ID collection and sharing

When activating the Adapty module, set ios.idfaCollectionDisabled (iOS) or android.adIdCollectionDisabled (Android) to true to disable the collection of advertising identifiers. The default value is false.

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

await adapty.activate({
  apiKey: 'YOUR_PUBLIC_SDK_KEY',
  params: {
    ios: {
      idfaCollectionDisabled: true,
    },
    android: {
      adIdCollectionDisabled: 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 mediaCache to override the default cache settings:

await adapty.activate({
  apiKey: 'YOUR_PUBLIC_SDK_KEY',
  params: {
    mediaCache: {
      memoryStorageTotalCostLimit: 200 * 1024 * 1024, // Optional: memory cache size in bytes
      memoryStorageCountLimit: 2147483647,            // Optional: max number of items in memory
      diskStorageSizeLimit: 200 * 1024 * 1024,       // Optional: disk cache size in bytes
    },
  }
});

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.

Enable local access levels (Android)

By default, local access levels are enabled on iOS and disabled on Android. To enable them on Android as well, set localAccessLevelAllowed to true:

await adapty.activate({
    apiKey: 'YOUR_PUBLIC_SDK_KEY',
    params: {
        android: {
            localAccessLevelAllowed: true,
        },
    }
});

Clear data on backup restore

When clearDataOnBackup is set to true, the SDK detects when the app is restored from an iCloud backup and deletes all locally stored SDK data, including cached profile information, product details, and paywalls. The SDK then initializes with a clean state. Default value is false.

Note

Only local SDK cache is deleted. Transaction history with Apple and user data on Adapty servers remain unchanged.

await adapty.activate({
    apiKey: 'YOUR_PUBLIC_SDK_KEY',
    params: {
        ios: {
            clearDataOnBackup: true,
        },
    }
});

Store messages handling

Info

This parameter is available starting from SDK version 4.3.0.

By default, StoreKit shows App Store messages — price increase consent requests, billing issue notices, and win-back offers — on its own while your app is open, and the SDK requests Google Play messages, such as declined payment notices, every time an Activity of your app starts after activate. To choose when your app shows them, set storeMessagesHandling to 'manual'. The default value is 'auto'.

await adapty.activate({
  apiKey: 'YOUR_PUBLIC_SDK_KEY',
  params: {
    storeMessagesHandling: 'manual',
  }
});

In manual mode, the stores don’t show messages on their own, so your app must call showStoreMessages. See how in Control store messages.

Enable Adapty Attribution

Info

This parameter is available starting from SDK version 4.1.

If you use Adapty Attribution, set adaptyAttributionEnabled to true when activating the SDK. The default value is false: without this parameter, the SDK doesn’t register installs or deliver installation details to your app. In SDK versions below 4.1, Adapty Attribution is enabled automatically.

await adapty.activate({
  apiKey: 'YOUR_PUBLIC_SDK_KEY',
  params: {
    adaptyAttributionEnabled: true,
  }
});

Development environment tips

Troubleshoot SDK activation errors on Capacitor’s live-reload

When developing with the Adapty SDK in Capacitor, you may encounter the error: Adapty can only be activated once. Ensure that the SDK activation call is not made more than once.

This occurs because Capacitor’s live-reload feature triggers multiple activation calls during development. To prevent this, use the __ignoreActivationOnFastRefresh option set to the Capacitor’s development mode flag – it will differ depending on the bundle you are using.

try {
  await adapty.activate({
    apiKey: 'YOUR_PUBLIC_SDK_KEY',
    params: {
        // Set your development environment variable
      __ignoreActivationOnFastRefresh: true,
    }
  });
} catch (error) {
  console.error('Failed to activate Adapty SDK:', error);
  // Handle the error appropriately for your app
}
Note

With this option enabled, the SDK skips the whole activation call once it has been activated, so changes to activation parameters don’t take effect on a live reload. To apply new activation parameters, fully close the app and launch it again.

Troubleshooting

App crashes on launch on iOS 15–17

If your app crashes on launch on iOS 15–17 with Library not loaded: …/SwiftUICore.framework/SwiftUICore, the product name App causes it. With this name, the Capacitor default, Xcode 26 links the app to SwiftUICore directly, and iOS 15–17 can’t load this library.

To prevent the crash, in the Build Settings of the App target, add the following values to Other Linker Flags:

-Xlinker -ignore_auto_link_library -Xlinker SwiftUICore

Minimum iOS version error

Note

This applies to CocoaPods-based projects: on SDK 3.x, and on SDK 4.2.0 and later with the CocoaPods option. On Swift Package Manager there is no Podfile — set your deployment target to 15.0 in Xcode instead.

If you get a minimum iOS version error, update your Podfile:

-platform :ios, '14.0'
+platform :ios, '15.0'

Android backup rules (Auto Backup configuration)

Some SDKs (including Adapty) ship their own Android Auto Backup configuration. If you use multiple SDKs that define backup rules, the Android manifest merger can fail with an error mentioning android:fullBackupContent, android:dataExtractionRules, or android:allowBackup.

Typical error symptoms: Manifest merger failed: Attribute application@dataExtractionRules value=(@xml/your_data_extraction_rules) is also present at [com.other.sdk:library:1.0.0] value=(@xml/other_sdk_data_extraction_rules)

Note

These changes should be made in your Android platform directory (typically located in your project’s android/ folder).

To resolve this, you need to:

  • Tell the manifest merger to use your app’s values for backup-related attributes.

  • Create backup rule files that merge Adapty’s rules with rules from other SDKs.

1. Add the tools namespace to your manifest

In your AndroidManifest.xml file, ensure the root <manifest> tag includes tools:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.example.app">

    ...
</manifest>

2. Override backup attributes in <application>

In the same AndroidManifest.xml file, update the <application> tag so that your app provides the final values and tells the manifest merger to replace library values:

<application
android:name=".App"
android:allowBackup="true"
android:fullBackupContent="@xml/sample_backup_rules"           
android:dataExtractionRules="@xml/sample_data_extraction_rules"
tools:replace="android:fullBackupContent,android:dataExtractionRules">

    ...
</application>

If any SDK also sets android:allowBackup, include it in tools:replace as well:

tools:replace="android:allowBackup,android:fullBackupContent,android:dataExtractionRules"

3. Create merged backup rules files

Create XML files in your Android project’s res/xml/ directory that combine Adapty’s rules with rules from other SDKs. Android uses different backup rule formats depending on the OS version, so creating both files ensures compatibility across all Android versions your app supports.

Note

The examples below show AppsFlyer as a sample third-party SDK. Replace or add rules for any other SDKs you’re using in your app.

For Android 12 and higher (uses the new data extraction rules format):

<?xml version="1.0" encoding="utf-8"?>
<data-extraction-rules>
    <cloud-backup>
        
        <exclude domain="sharedpref" path="appsflyer-data"/>
        <exclude domain="sharedpref" path="appsflyer-purchase-data"/>
        <exclude domain="database" path="afpurchases.db"/>
        
        <exclude domain="sharedpref" path="AdaptySDKPrefs.xml"/>
    </cloud-backup>

    <device-transfer>
        
        <exclude domain="sharedpref" path="appsflyer-data"/>
        <exclude domain="sharedpref" path="appsflyer-purchase-data"/>
        <exclude domain="database" path="afpurchases.db"/>
        <exclude domain="sharedpref" path="AdaptySDKPrefs.xml"/>
    </device-transfer>
</data-extraction-rules>

For Android 11 and lower (uses the legacy full backup content format):

<?xml version="1.0" encoding="utf-8"?>
<full-backup-content>
    
    <exclude domain="sharedpref" path="appsflyer-data"/>

    
    <exclude domain="sharedpref" path="AdaptySDKPrefs.xml"/>

    
Tip

After changing native Android files, run npx cap sync android so Capacitor picks up the updated resources if you regenerate the platform.

Purchases fail after returning from another app in Android

If the Activity that starts the purchase flow uses a non-default launchMode, Android may recreate or reuse it incorrectly when the user returns from Google Play, a banking app, or a browser. This can cause the purchase result to be lost or treated as canceled.

To ensure purchases work correctly, use only standard or singleTop launch modes for the Activity that starts the purchase flow, and avoid any other modes.

In your AndroidManifest.xml, ensure the Activity that starts the purchase flow is set to standard or singleTop:

<activity
    android:name=".MainActivity"
    android:launchMode="standard" />

Swift 6 build errors caused by Podfile SWIFT_VERSION override

Note

This applies when the native iOS SDKs install as CocoaPods pods: in SDK 3.x, and in SDK 4.2.0 and later with the CocoaPods option. When they install as Swift packages, a SWIFT_VERSION override in post_install doesn’t reach them.

When building your Capacitor app for iOS, you may see Swift 6 compilation errors on Adapty pod targets. Typical symptoms include @Sendable mismatches in AdaptyUIBuilderLogic, missing Sendable conformance on Adapty types, or actor isolation errors.

The Adapty pods declare s.swift_version = '6.0' and require Swift 6 to build. Your own app code can stay on Swift 5 — only the Adapty pod targets (Adapty, AdaptyUI, AdaptyUIBuilder, AdaptyLogger, AdaptyPlugin, and in SDK 4.2.0 and later AdaptyCodable) need to build with Swift 6.

The most common cause is a post_install hook in ios/App/Podfile that rewrites SWIFT_VERSION for every pod target:

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['SWIFT_VERSION'] = '5.9'
    end
  end
end

Fix: Exclude the Adapty pod targets from the override:

post_install do |installer|
  installer.pods_project.targets.each do |target|
    next if %w[Adapty AdaptyUI AdaptyUIBuilder AdaptyLogger AdaptyPlugin AdaptyCodable].include?(target.name)
    target.build_configurations.each do |config|
      config.build_settings['SWIFT_VERSION'] = '5.9'
    end
  end
end

Then run npx cap sync ios and rebuild.

To verify, open ios/App/Pods/Pods.xcodeproj, select the Adapty pod target → Build Settings → Swift Language Version. It should be Swift 6.