Install & configure iOS SDK
Adapty SDK includes two key modules for seamless integration into your mobile 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.
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.
For a complete implementation walkthrough, you can also see the videos:
Requirements
While the SDK technically supports iOS 13.0+ for the core module, iOS 15.0+ is effectively required for practical use since:
- All StoreKit 2 features require iOS 15.0+
- AdaptyUI module is iOS 15.0+ only
Install Adapty SDK
Activate Adapty module of Adapty SDK
Activate the Adapty SDK in your app code.
The Adapty SDK only needs to be activated once in your app.
To get your Public SDK Key:
- Go to Adapty Dashboard and navigate to App settings → General.
- From the Api keys section, copy the Public SDK Key (NOT the Secret Key).
- Replace
"YOUR_PUBLIC_SDK_KEY"in the code.
- 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.
Activate AdaptyUI module of Adapty SDK
If you plan to use Paywall Builder and have installed AdaptyUI module, you also need to activate AdaptyUI.
In your code, you must activate the core Adapty module before activating AdaptyUI.
Optionally, when activating AdaptyUI, you can override default caching settings for paywalls.
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:
| Level | Description |
|---|---|
error | Only errors will be logged |
warn | Errors and messages from the SDK that do not cause critical errors, but are worth paying attention to will be logged |
info | Errors, warnings, and various information messages will be logged |
verbose | Any additional information that may be useful during debugging, such as function calls, API queries, etc. will be logged |
let configurationBuilder = AdaptyConfiguration
.builder(withAPIKey: "YOUR_PUBLIC_SDK_KEY")
.with(logLevel: .verbose) // recommended for development
Redirect the logging system messages
If you need to send Adapty’s log messages to your system or save them to a file, use the setLogHandler method and implement your custom logging logic inside it. This handler receives log records containing message content and severity level.
Adapty.setLogHandler { record in
writeToLocalFile("Adapty \(record.level): \(record.message)")
}
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 IDFA collection and sharing
When activating the Adapty module, set idfaCollectionDisabled to true to disable IDFA collection and sharing.
Use this parameter to comply with App Store Review Guidelines or avoid triggering the App Tracking Transparency prompt when IDFA isn’t needed for your app. The default value is false. For more details on IDFA collection, refer to the Analytics integration section.
let configurationBuilder =
AdaptyConfiguration
.builder(withAPIKey: "YOUR_PUBLIC_SDK_KEY")
.with(idfaCollectionDisabled: true)
Disable IP 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.
let configurationBuilder =
AdaptyConfiguration
.builder(withAPIKey: "YOUR_PUBLIC_SDK_KEY")
.with(ipAddressCollectionDisabled: true)
Media cache configuration for paywalls in AdaptyUI
Please note that the AdaptyUI configuration is optional. You can activate the AdaptyUI module without its config. However, if you use the config, all parameters are required.
import AdaptyUI
// Configure AdaptyUI
let adaptyUIConfiguration = AdaptyUI.Configuration(
mediaCacheConfiguration: .init(
memoryStorageTotalCostLimit: 100 * 1024 * 1024,
memoryStorageCountLimit: .max,
diskStorageSizeLimit: 100 * 1024 * 1024
)
)
// Activate AdaptyUI
AdaptyUI.activate(configuration: adaptyUIConfiguration)
Parameters:
| Parameter | Presence | Description |
|---|---|---|
| memoryStorageTotalCostLimit | required | Total cost limit of the storage in bytes. |
| memoryStorageCountLimit | required | The item count limit of the memory storage. |
| diskStorageSizeLimit | required | The file size limit on disk of the storage in bytes. 0 means no limit. |
Transaction finishing behavior
This feature is available starting from SDK version 3.12.0.
By default, Adapty automatically finishes transactions after successful validation. However, if you need advanced transaction validation (such as server-side receipt validation, fraud detection, or custom business logic), you can configure the SDK to use manual transaction finishing.
let configurationBuilder = AdaptyConfiguration
.builder(withAPIKey: "YOUR_PUBLIC_SDK_KEY")
.with(transactionsFinishBehavior: .manual) // .auto is the default
See more details on how to finish transactions in the guide.
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.
Only local SDK cache is deleted. Transaction history with Apple and user data on Adapty servers remain unchanged.
let configurationBuilder = AdaptyConfiguration
.builder(withAPIKey: "YOUR_PUBLIC_SDK_KEY")
.with(clearDataOnBackup: true) // default – false