Adds a event listener for native event
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.
Fetches 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.
Optional
locale: stringThe locale of the desired paywall.
Optional
params: GetPaywallParamsInput = ...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.
Optional
locale: stringThe locale of the desired paywall.
Optional
params: GetPaywallForDefaultAudienceParamsInput = ...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 getPaywall method.
A promise that resolves with a list of AdaptyPaywallProduct associated with a provided paywall.
const paywall = await adapty.getPaywall('paywall_id');
const products = await adapty.getPaywallProducts(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 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
Logs an onboarding screen view event.
In order for you to be able to analyze user behavior at this critical stage without leaving Adapty, we have implemented the ability to send dedicated events every time a user visits yet another onboarding screen.
The number of the screen that was shown to the user.
Optional
onboardingName: stringThe name of the onboarding.
Optional
screenName: stringThe name of the screen.
resolves when the event is logged
Even though there is only one mandatory parameter in this function, we recommend that you think of names for all the screens, as this will make the work of analysts during the data examination phase much easier.
adapty.logShowOnboarding(1, 'onboarding_name', 'screen_name');
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
Whenever you show a paywall to your user, call this function to log the event, and it will be accumulated in the paywall metrics.
const paywall = await adapty.getPaywall('paywall_id');
// ...after opening the paywall
adapty.logShowPaywall(paywall);
Logs out the current user. You can then login the user using identify method.
Performs a purchase of the specified product.
All the available promotions will be applied automatically.
The product to e purchased. You can get the product using getPaywallProducts method.
Optional
params: MakePurchaseParamsInput = {}Additional parameters for the purchase.
A Promise that resolves to an AdaptyProfile object containing the user's profile information after the purchase is made.
Successful purchase will also result in a call to 'onLatestProfileLoad'
listener.
You can use addEventListener to subscribe to this event and handle
the purchase result outside of this thread.
If an error occurs during the purchase process or while decoding the response from the native SDK. Some of the possible errors are:
try {
const paywall = await adapty.getPaywall('onboarding');
const products = await adapty.getPaywallProducts(paywall);
const product = products[0];
const profile = await adapty.makePurchase(product);
// successfull purchase
} catch (error) {
// handle error
}
Restores user purchases and updates the profile.
resolves with the updated profile
AdaptyError if an error occurs during the restore proccess or while decoding the response
Sets the fallback paywalls.
Fallback paywalls will be used if the SDK fails to fetch the paywalls from the dashboard. It is not designed to be used for the offline flow, as products are not cached in Adapty.
resolves when fallback paywalls 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
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.
variationId
property of AdaptyPaywall
transactionId
property of AdaptySubscription
Updates an attribution data for the current user.
An object containing attribution data.
The source of the attribution data.
Optional
networkUserId: stringThe network user ID.
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);
Generated using TypeDoc
Entry point for the Adapty SDK. All Adapty methods are available through this class.