Adapty

Main entry point for interacting with the Adapty SDK.

The Adapty object provides access to all core SDK functionality, including:

  • Activating and configuring the SDK

  • Managing user profiles and purchases

  • Fetching and presenting paywalls and onboardings

  • Observing subscription updates and installation details

Each public method corresponds to a specific SDK capability. Most functions will return AdaptyResult that can be used to handle success and errors.

Functions

Link copied to clipboard
open suspend override fun activate(configuration: AdaptyConfig): AdaptyResult<Unit>

Initializes the Adapty SDK with the specified AdaptyConfig.

Link copied to clipboard
suspend fun Adapty.activate(context: Context, config: AdaptyConfig)

Activates the Adapty SDK using the provided context and config.

Link copied to clipboard
open suspend override fun createWebPaywallUrl(paywall: AdaptyPaywall?, product: AdaptyPaywallProduct?): AdaptyResult<String>

Creates a URL for a web paywall or product.

Link copied to clipboard

Returns the current installation status of the app.

Link copied to clipboard
open suspend override fun getOnboarding(placementId: String, locale: String?, fetchPolicy: AdaptyPaywallFetchPolicy, loadTimeout: Duration): AdaptyResult<AdaptyOnboarding>

Fetches an onboarding flow by placement ID.

Link copied to clipboard
open suspend override fun getOnboardingForDefaultAudience(placementId: String, locale: String?, fetchPolicy: AdaptyPaywallFetchPolicy): AdaptyResult<AdaptyOnboarding>

Fetches onboarding flow for the default audience. This method enables you to retrieve the onboarding from the Default Audience without having to wait for the Adapty SDK to send all the user information required for segmentation to the server.

Link copied to clipboard
open suspend override fun getPaywall(placementId: String, locale: String?, fetchPolicy: AdaptyPaywallFetchPolicy, loadTimeout: Duration): AdaptyResult<AdaptyPaywall>

Fetches a paywall by placement ID. Read more on the Adapty Documentation

Link copied to clipboard
open suspend override fun getPaywallForDefaultAudience(placementId: String, locale: String?, fetchPolicy: AdaptyPaywallFetchPolicy): AdaptyResult<AdaptyPaywall>

Fetches paywall for the default audience. This method enables you to retrieve the paywall from the Default Audience without having to wait for the Adapty SDK to send all the user information required for segmentation to the server.

Link copied to clipboard

Retrieves the products for a given paywall.

Link copied to clipboard
open suspend override fun getProfile(): AdaptyResult<AdaptyProfile>

Retrieves the latest user profile.

Link copied to clipboard
open suspend override fun identify(customerUserId: String, iosAppAccountToken: String?, androidObfuscatedAccountId: String?): AdaptyResult<Unit>

Associates the current user with a custom user identifier in your system.

Link copied to clipboard
open suspend override fun isActivated(): Boolean

Checks whether the SDK is activated.

Link copied to clipboard
open suspend override fun logout(): AdaptyResult<Unit>

Logs out the current user.

Link copied to clipboard
open suspend override fun logShowPaywall(paywall: AdaptyPaywall): AdaptyResult<Unit>

Logs a paywall view for analytics purposes. Call this method to notify Adapty SDK, that particular paywall was shown to user. Adapty helps you to measure the performance of the paywalls. We automatically collect all the metrics related to purchases except for paywall views. This is because only you know when the paywall was shown to a customer. Whenever you show a paywall to your user, call .logShowPaywall(paywall) to log the event, and it will be accumulated in the paywall metrics.

Link copied to clipboard

Performs a purchase for the specified product. Read more on the Adapty Documentation

Link copied to clipboard
open suspend override fun openWebPaywall(paywall: AdaptyPaywall?, product: AdaptyPaywallProduct?, openIn: AdaptyWebPresentation): AdaptyResult<Unit>

Opens a web-based paywall or a specific product.

Link copied to clipboard
open suspend override fun presentCodeRedemptionSheet(): AdaptyResult<Unit>

Ios ONLY. Presents a code redemption sheet on iOS that enables the user to redeem codes provided by your app.

Link copied to clipboard
open suspend override fun reportTransaction(transactionId: String, variationId: String?): AdaptyResult<Unit>

In Observer mode, Adapty SDK doesn’t know, where the purchase was made from. If you display products using our Paywalls or A/B Tests, you can manually assign variation to the purchase. After doing this, you’ll be able to see metrics in Adapty Dashboard.

Link copied to clipboard
open suspend override fun restorePurchases(): AdaptyResult<AdaptyProfile>

Restores previous purchases for the current user.

Link copied to clipboard
open suspend override fun setFallback(assetId: String): AdaptyResult<Unit>

Sets fallback paywalls from a local asset. You should pass exactly the same payload you’re getting from Adapty backend. You can copy it from Adapty Dashboard. Adapty allows you to provide fallback paywalls that will be used when a user opens the app for the first time and there’s no internet connection or in the rare case when Adapty backend is down and there’s no cache on the device.

Link copied to clipboard
open suspend override fun setIntegrationIdentifier(key: String, value: String): AdaptyResult<Unit>

Sets an integration identifier for the profile.

Link copied to clipboard
open override fun setLogLevel(logLevel: AdaptyLogLevel)

Sets the SDK log level.

Link copied to clipboard
open override fun setOnInstallationDetailsListener(onInstallationDetailsListener: OnInstallationDetailsListener?)

Sets a listener to receive installation details related to Adapty’s User Acquisition feature.

Link copied to clipboard
open override fun setOnProfileUpdatedListener(onProfileUpdatedListener: OnProfileUpdatedListener?)

Sets a listener to automatically receive profile updates in your app.

Link copied to clipboard
open suspend override fun updateAttribution(attribution: Map<String, Any>, source: String): AdaptyResult<Unit>

Updates attribution (conversion) data for the current profile. Read more on the Adapty Documentation

Link copied to clipboard
open suspend override fun updateCollectingRefundDataConsent(consent: Boolean): AdaptyResult<Boolean>

Ios ONLY. Updates the user's consent for collecting refund data on iOS.

Link copied to clipboard
open suspend override fun updateProfile(params: AdaptyProfileParameters): AdaptyResult<Unit>

Updates the user's profile attributes such as email, phone, or custom fields. You can then use attributes to create user segments or just view them in CRM.

Link copied to clipboard
open suspend override fun updateRefundPreference(preference: AdaptyIosRefundPreference): AdaptyResult<Boolean>

Ios ONLY. Updates the refund preference for iOS.