Initializes the Adapty SDK.
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
useEffect(() => {
adapty.activate('YOUR_API_KEY'); // <-- pass your API key here (required)
}, []);
useEffect(() => {
adapty.activate('YOUR_API_KEY', { // <-- pass your API key here (required)
customerUserId: 'YOUR_USER_ID' // <-- pass your user identifier here (optional)
});
}, []);
A promise that resolves when the SDK is initialized.
AdaptyError Usually throws if the SDK is already activated or if the API key is invalid.
You can find it in your app settings in Adapty Dashboard App settings > General.
Fetches a paywall by its developer ID.
Adapty allows you remotely configure the products that will be displayed in your app. This way you don’t have to hardcode the products and can dynamically change offers or run A/B tests without app releases.
A promise that resolves with a requested paywall.
AdaptyError Throws an error:
The identifier of the desired paywall. This is the value you specified when you created the paywall in the Adapty Dashboard.
Optional
locale: stringThe locale of the desired paywall.
Fetches a list of products associated with a provided paywall.
const paywall = await adapty.getPaywall('paywall_id');
const products = await adapty.getPaywallProducts(paywall);
A promise that resolves with a list of Model.AdaptyProduct associated with a provided paywall.
a paywall to fetch products for. You can get it using getPaywall method.
Optional
params: GetPaywallProductsParamsInput = {}Optional parameters of type GetPaywallProductsParamsInput.
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.
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
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.
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');
resolves when the event is logged
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.
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 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);
resolves when the event is logged
object that was shown to the user.
Performs a purchase of the specified product.
All the available promotions will be applied automatically.
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.
A Promise that resolves to an Model.AdaptyProfile object containing the user's profile information after the purchase is made.
If an error occurs during the purchase process or while decoding the response from the native SDK. Some of the possible errors are: ErrorCode
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
}
The product to e purchased. You can get the product using getPaywallProducts method.
Restores user purchases and updates the profile.
resolves with the updated profile
Logs errors and other important information to help you understand what is going on.
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.
resolves when the log level is set
AdaptyError if the log level is invalid
new preferred log level
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 Model.AdaptyPaywall
transactionId
property of Model.AdaptyPurchase
Updates an attribution data for the current user.
const attribution = {
'Adjust Adid': 'adjust_adid',
'Adjust Network': 'adjust_network',
'Adjust Campaign': 'adjust_campaign',
'Adjust Adgroup': 'adjust_adgroup',
};
adapty.updateAttribution(attribution, 'adjust');
A promise that resolves when the attribution data is updated.
AdaptyError Throws if parameters are invalid or not provided.
An object containing attribution data.
The source of the attribution data.
Optional
networkUserId: stringThe network user ID.
— an object of parameters to update
Blocks the current thread until the SDK is initialized.
Applied automatically to all methods
if lockMethodsUntilReady
is set to true
in activate.
A promise that resolves when the SDK is initialized.
AdaptyError same error as activation or error if SDK is not activated
Generated using TypeDoc
Entry point for the Adapty SDK. All Adapty methods are available through this class.