Initializes the Adapty SDK.
You can find it in your app settings in Adapty Dashboard App settings > General.
Optional parameters of type ActivateParamsInput.
A promise that resolves when the SDK is initialized.
This method must be called in order for the SDK to work. It is preffered to call it as early as possible in the app lifecycle, so background activities can be performed and cache can be updated.
adapty.activate('YOUR_API_KEY'); // <-- pass your API key here (required)
adapty.activate('YOUR_API_KEY', { // <-- pass your API key here (required)
customerUserId: 'YOUR_USER_ID' // <-- pass your user identifier here (optional)
});
AdaptyError Usually throws if the SDK is already activated or if the API key is invalid.
Adds an event listener for the latest profile load event.
Adds an event listener for successful installation details retrieval.
Adds an event listener for installation details retrieval failures.
Enables mock mode.
OptionalmockConfig: AdaptyMockConfigOptional mock configuration
This method should be called before activate() if you want to test SDK methods without full activation (e.g., isActivated()). If bridge is already initialized, this method does nothing.
Important: Mock mode cannot be disabled at runtime. To switch back to production mode, you need to restart the app.
Gets the current installation status.
A promise that resolves with the installation status.
Installation status provides information about when the app was installed, how many times it has been launched, and other installation-related details. The status can be "not_available", "not_determined", or "determined" with details.
AdaptyError If an error occurs while retrieving the installation status.
Optionallocale: stringOptionallocale: stringFetches the paywall by the specified placement.
The identifier of the desired placement. This is the value you specified when you created the placement in the Adapty Dashboard.
Optionallocale: stringThe locale of the desired paywall.
Optionalparams: GetPlacementParamsInput = ...Additional parameters for retrieving paywall.
A promise that resolves with a requested paywall.
With Adapty, you can remotely configure the products and offers in your app by simply adding them to paywalls – no need for hardcoding them. The only thing you hardcode is the placement ID. This flexibility allows you to easily update paywalls, products, and offers, or run A/B tests, all without the need for a new app release.
AdaptyError Throws an error:
Fetches the paywall of the specified placement for the All Users audience.
The identifier of the desired placement. This is the value you specified when you created the placement in the Adapty Dashboard.
Optionallocale: stringThe locale of the desired paywall.
Optionalparams: GetPlacementForDefaultAudienceParamsInput = ...Additional parameters for retrieving paywall.
A promise that resolves with a requested paywall.
With Adapty, you can remotely configure the products and offers in your app by simply adding them to paywalls – no need for hardcoding them. The only thing you hardcode is the placement ID. This flexibility allows you to easily update paywalls, products, and offers, or run A/B tests, all without the need for a new app release.
However, it’s crucial to understand that the recommended approach is to fetch the paywall
through the placement ID by the getPaywall method.
The getPaywallForDefaultAudience method should be a last resort due to its significant drawbacks.
See docs for more details
AdaptyError Throws an error:
Fetches a list of products associated with a provided paywall.
a paywall to fetch products for. You can get it using Adapty.getPaywall method.
A promise that resolves with a list of Model.AdaptyPaywallProduct associated with a provided paywall.
Fetches a user profile.
Allows you to define the level of access, as well as other parameters.
The getProfile method provides the most up-to-date result as it always tries to query the API. If for some reason (e.g. no internet connection), the Adapty SDK fails to retrieve information from the server, the data from cache will be returned. It is also important to note that the Adapty SDK updates Model.AdaptyProfile cache on a regular basis, in order to keep this information as up-to-date as possible.
Logs in a user with a provided customerUserId.
If you don't have a user id on SDK initialization, you can set it later at any time with this method. The most common cases are after registration/authorization when the user switches from being an anonymous user to an authenticated user.
unique user id
Optionalparams: IdentifyParamsInputAdditional parameters for identification
Logs out the current user. You can then login the user using Adapty.identify method.
Logs a paywall view event.
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.
object that was shown to the user.
resolves when the event is logged
Performs a purchase of the specified product.
All available promotions will be applied automatically.
The product to be purchased. You can get the product using Adapty.getPaywallProducts method.
Optionalparams: MakePurchaseParamsInput = {}Additional parameters for the purchase.
A Promise that resolves to the Model.AdaptyPurchaseResult object
containing details about the purchase. If the result is 'success', it also includes the updated user's profile.
Successful purchase will also result in a call to the 'onLatestProfileLoad' listener.
You can use Adapty.addEventListener to subscribe to this event and handle
the purchase result outside of this thread.
Removes all attached event listeners
Sets the variation ID of the purchase.
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.
transactionId property of Model.AdaptySubscription
OptionalvariationId: stringvariationId property of Model.AdaptyPaywall
Restores user purchases and updates the profile.
resolves with the updated profile
AdaptyError if an error occurs during the restore process or while decoding the response
Sets the fallback paywalls.
Fallback file will be used if the SDK fails to fetch the paywalls or onboardings from the dashboard. It is not designed to be used for the offline flow, as products are not cached in Adapty.
resolves when fallback placements are saved
Sets the preferred log level.
By default, the log level is set to error.
new preferred log level
resolves when the log level is set
There are four levels available:
error: only errors will be logged
warn: messages from the SDK that do not cause critical errors, but are worth paying attention to
info: various information messages, such as those that log the lifecycle of various modules
verbose: any additional information that may be useful during debugging, such as function calls, API queries, etc.
AdaptyError if the log level is invalid
Updates an attribution data for the current user.
An object containing attribution data.
The source of the attribution data.
A promise that resolves when the attribution data is updated.
const attribution = {
'Adjust Adid': 'adjust_adid',
'Adjust Network': 'adjust_network',
'Adjust Campaign': 'adjust_campaign',
'Adjust Adgroup': 'adjust_adgroup',
};
adapty.updateAttribution(attribution, 'adjust');
AdaptyError Throws if parameters are invalid or not provided.
Updates a profile for the current user.
— an object of parameters to update
AdaptyError If parameters are invalid or there is a network error.
const profile = {
email: '[email protected]',
phone: '+1234567890',
};
await adapty.updateProfile(profile);
Entry point for the Adapty SDK. All Adapty methods are available through this class.