Object Adapty
-
- All Implemented Interfaces:
public class Adapty
-
-
Field Summary
Fields Modifier and Type Field Description private static AdaptyLogLevellogLevelprivate final static BooleanisActivatedpublic final static AdaptyINSTANCE
-
Method Summary
Modifier and Type Method Description final static Unitactivate(Context context, AdaptyConfig config)Use this method to initialize the Adapty SDK. final static Unitactivate(Context context, String appKey, Boolean observerMode, String customerUserId)Use this method to initialize the Adapty SDK. final static Unitactivate(Context context, String appKey, Boolean observerMode)Use this method to initialize the Adapty SDK. final static Unitactivate(Context context, String appKey)Use this method to initialize the Adapty SDK. final static Unitidentify(String customerUserId, ErrorCallback callback)Use this method for identifying user with it’s user id in your system. final static UnitupdateProfile(AdaptyProfileParameters params, ErrorCallback callback)You can set optional attributes such as email, phone number, etc, to the user of your app. final static UnitgetProfile(ResultCallback<AdaptyProfile> callback)The main function for getting a user profile. final static UnitgetPaywall(String placementId, String locale, AdaptyPlacementFetchPolicy fetchPolicy, TimeInterval loadTimeout, ResultCallback<AdaptyPaywall> callback)Fetches the paywall by the specified placement. final static UnitgetPaywall(String placementId, String locale, AdaptyPlacementFetchPolicy fetchPolicy, ResultCallback<AdaptyPaywall> callback)Fetches the paywall by the specified placement. final static UnitgetPaywall(String placementId, String locale, ResultCallback<AdaptyPaywall> callback)Fetches the paywall by the specified placement. final static UnitgetPaywall(String placementId, ResultCallback<AdaptyPaywall> callback)Fetches the paywall by the specified placement. final static UnitgetPaywallProducts(AdaptyPaywall paywall, ResultCallback<List<AdaptyPaywallProduct>> callback)Once you have an AdaptyPaywall, fetch corresponding products list using this method. final static UnitgetOnboarding(String placementId, String locale, AdaptyPlacementFetchPolicy fetchPolicy, TimeInterval loadTimeout, ResultCallback<AdaptyOnboarding> callback)final static UnitgetOnboarding(String placementId, String locale, AdaptyPlacementFetchPolicy fetchPolicy, ResultCallback<AdaptyOnboarding> callback)final static UnitgetOnboarding(String placementId, String locale, ResultCallback<AdaptyOnboarding> callback)final static UnitgetOnboarding(String placementId, ResultCallback<AdaptyOnboarding> callback)final static UnitmakePurchase(Activity activity, AdaptyPaywallProduct product, AdaptySubscriptionUpdateParameters subscriptionUpdateParams, Boolean isOfferPersonalized, ResultCallback<AdaptyPurchaseResult> callback)To make the purchase, you have to call this method. final static UnitmakePurchase(Activity activity, AdaptyPaywallProduct product, AdaptyPurchaseParameters params, ResultCallback<AdaptyPurchaseResult> callback)To make the purchase, you have to call this method. final static UnitmakePurchase(Activity activity, AdaptyPaywallProduct product, ResultCallback<AdaptyPurchaseResult> callback)To make the purchase, you have to call this method. final static UnitrestorePurchases(ResultCallback<AdaptyProfile> callback)To restore purchases, you have to call this method. final static UnitupdateAttribution(Object attribution, String source, ErrorCallback callback)final static UnitsetIntegrationIdentifier(String key, String value, ErrorCallback callback)final static UnitgetCurrentInstallationStatus(ResultCallback<AdaptyInstallationStatus> callback)final static UnitreportTransaction(TransactionInfo transactionInfo, String variationId, ResultCallback<AdaptyProfile> callback)In Observer mode, Adapty SDK doesn’t know, where the purchase was made from. final static UnitreportTransaction(TransactionInfo transactionInfo, ResultCallback<AdaptyProfile> callback)In Observer mode, Adapty SDK doesn’t know, where the purchase was made from. final static Unitlogout(ErrorCallback callback)You can logout the user anytime by calling this method. final static UnitsetOnProfileUpdatedListener(OnProfileUpdatedListener onProfileUpdatedListener)Implement this method to receive automatic profile updates. final static UnitsetOnInstallationDetailsListener(OnInstallationDetailsListener onInstallationDetailsListener)final static UnitsetLogHandler(AdaptyLogHandler logHandler)Override the default logger behavior using this method. final static UnitsetFallback(FileLocation location, ErrorCallback callback)To set fallback paywalls, use this method. final static UnitsetFallback(FileLocation location)To set fallback paywalls, use this method. final static UnitlogShowPaywall(AdaptyPaywall paywall, ErrorCallback callback)Call this method to notify Adapty SDK, that particular paywall was shown to user. final static UnitlogShowPaywall(AdaptyPaywall paywall)Call this method to notify Adapty SDK, that particular paywall was shown to user. final static UnitlogShowOnboarding(String name, String screenName, @IntRange(from = 1) Integer screenOrder, ErrorCallback callback)Call this method to keep track of the user’s steps while onboarding. final static UnitlogShowOnboarding(String name, String screenName, @IntRange(from = 1) Integer screenOrder)Call this method to keep track of the user’s steps while onboarding. final static UnitgetPaywallForDefaultAudience(String placementId, String locale, AdaptyPlacementFetchPolicy fetchPolicy, ResultCallback<AdaptyPaywall> callback)Fetches the paywall of the specified placement for the All Users audience. final static UnitgetPaywallForDefaultAudience(String placementId, String locale, ResultCallback<AdaptyPaywall> callback)Fetches the paywall of the specified placement for the All Users audience. final static UnitgetPaywallForDefaultAudience(String placementId, ResultCallback<AdaptyPaywall> callback)Fetches the paywall of the specified placement for the All Users audience. final static UnitgetOnboardingForDefaultAudience(String placementId, String locale, AdaptyPlacementFetchPolicy fetchPolicy, ResultCallback<AdaptyOnboarding> callback)final static UnitgetOnboardingForDefaultAudience(String placementId, String locale, ResultCallback<AdaptyOnboarding> callback)final static UnitgetOnboardingForDefaultAudience(String placementId, ResultCallback<AdaptyOnboarding> callback)final static AdaptyLogLevelgetLogLevel()final static UnitsetLogLevel(static AdaptyLogLevel logLevel)final static BooleanisActivated()-
-
Method Detail
-
activate
final static Unit activate(Context context, AdaptyConfig config)
Use this method to initialize the Adapty SDK.
- Parameters:
context- Application context.config- An AdaptyConfig object.
-
activate
final static Unit activate(Context context, String appKey, Boolean observerMode, String customerUserId)
Use this method to initialize the Adapty SDK.
- Parameters:
context- Application context.appKey- You can find it in your app settings in Adapty Dashboard App settings General.observerMode- A boolean value controlling Observer mode.customerUserId- User identifier in your system.
-
activate
final static Unit activate(Context context, String appKey, Boolean observerMode)
Use this method to initialize the Adapty SDK.
- Parameters:
context- Application context.appKey- You can find it in your app settings in Adapty Dashboard App settings General.observerMode- A boolean value controlling Observer mode.
-
activate
final static Unit activate(Context context, String appKey)
Use this method to initialize the Adapty SDK.
- Parameters:
context- Application context.appKey- You can find it in your app settings in Adapty Dashboard App settings General.
-
identify
final static Unit identify(String customerUserId, ErrorCallback callback)
Use this method for identifying user with it’s user id in your system.
If you don’t have a user id on SDK configuration, you can set it later at any time with
.identify()method. The most common cases are after registration/authorization when the user switches from being an anonymous user to an authenticated user.Should not be called before activate
- Parameters:
customerUserId- User identifier in your system.callback- An result containing the optional AdaptyError.
-
updateProfile
final static Unit updateProfile(AdaptyProfileParameters params, ErrorCallback callback)
You can set optional attributes such as email, phone number, etc, to the user of your app. You can then use attributes to create user segments or just view them in CRM.
Should not be called before activate
- Parameters:
params- Use AdaptyProfileParameters.Builder class to build this object.callback- A result containing the optional AdaptyError.
-
getProfile
final static Unit getProfile(ResultCallback<AdaptyProfile> callback)
The main function for getting a user profile. Allows you to define the level of access, as well as other parameters.
The
getProfilemethod 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.Should not be called before activate
- Parameters:
callback- A result containing the AdaptyProfile object.
-
getPaywall
final static Unit getPaywall(String placementId, String locale, AdaptyPlacementFetchPolicy fetchPolicy, TimeInterval loadTimeout, ResultCallback<AdaptyPaywall> callback)
Fetches the paywall by the specified placement.
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.
Should not be called before activate
- Parameters:
placementId- The identifier of the desired placement.locale- This parameter is expected to be a language code composed of one or more subtags separated by the "-" character.fetchPolicy- By default SDK will try to load data from server and will return cached data in case of failure.loadTimeout- This value limits the timeout for this method.callback- A result containing the AdaptyPaywall object.
-
getPaywall
final static Unit getPaywall(String placementId, String locale, AdaptyPlacementFetchPolicy fetchPolicy, ResultCallback<AdaptyPaywall> callback)
Fetches the paywall by the specified placement.
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.
Should not be called before activate
- Parameters:
placementId- The identifier of the desired placement.locale- This parameter is expected to be a language code composed of one or more subtags separated by the "-" character.fetchPolicy- By default SDK will try to load data from server and will return cached data in case of failure.callback- A result containing the AdaptyPaywall object.
-
getPaywall
final static Unit getPaywall(String placementId, String locale, ResultCallback<AdaptyPaywall> callback)
Fetches the paywall by the specified placement.
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.
Should not be called before activate
- Parameters:
placementId- The identifier of the desired placement.locale- This parameter is expected to be a language code composed of one or more subtags separated by the "-" character.callback- A result containing the AdaptyPaywall object.
-
getPaywall
final static Unit getPaywall(String placementId, ResultCallback<AdaptyPaywall> callback)
Fetches the paywall by the specified placement.
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.
Should not be called before activate
- Parameters:
placementId- The identifier of the desired placement.callback- A result containing the AdaptyPaywall object.
-
getPaywallProducts
final static Unit getPaywallProducts(AdaptyPaywall paywall, ResultCallback<List<AdaptyPaywallProduct>> callback)
Once you have an AdaptyPaywall, fetch corresponding products list using this method.
Should not be called before activate
- Parameters:
paywall- The AdaptyPaywall for which you want to get products.callback- A result containing the AdaptyPaywallProduct list.
-
getOnboarding
final static Unit getOnboarding(String placementId, String locale, AdaptyPlacementFetchPolicy fetchPolicy, TimeInterval loadTimeout, ResultCallback<AdaptyOnboarding> callback)
-
getOnboarding
final static Unit getOnboarding(String placementId, String locale, AdaptyPlacementFetchPolicy fetchPolicy, ResultCallback<AdaptyOnboarding> callback)
-
getOnboarding
final static Unit getOnboarding(String placementId, String locale, ResultCallback<AdaptyOnboarding> callback)
-
getOnboarding
final static Unit getOnboarding(String placementId, ResultCallback<AdaptyOnboarding> callback)
-
makePurchase
final static Unit makePurchase(Activity activity, AdaptyPaywallProduct product, AdaptySubscriptionUpdateParameters subscriptionUpdateParams, Boolean isOfferPersonalized, ResultCallback<AdaptyPurchaseResult> callback)
To make the purchase, you have to call this method.
Should not be called before activate
- Parameters:
activity- An Activity instance.product- An AdaptyPaywallProduct object retrieved from the paywall.subscriptionUpdateParams- An AdaptySubscriptionUpdateParameters object, used when you need a subscription to be replaced with another one, read more.isOfferPersonalized- Indicates whether the price is personalized, read more.callback- The result includes an AdaptyPurchaseResult object, which provides details about the purchase.
-
makePurchase
final static Unit makePurchase(Activity activity, AdaptyPaywallProduct product, AdaptyPurchaseParameters params, ResultCallback<AdaptyPurchaseResult> callback)
To make the purchase, you have to call this method.
Should not be called before activate
- Parameters:
activity- An Activity instance.product- An AdaptyPaywallProduct object retrieved from the paywall.params- Optional AdaptyPurchaseParameters used to provide additional purchase options.callback- The result includes an AdaptyPurchaseResult object, which provides details about the purchase.
-
makePurchase
final static Unit makePurchase(Activity activity, AdaptyPaywallProduct product, ResultCallback<AdaptyPurchaseResult> callback)
To make the purchase, you have to call this method.
Should not be called before activate
- Parameters:
activity- An Activity instance.product- An AdaptyPaywallProduct object retrieved from the paywall.callback- The result includes an AdaptyPurchaseResult object, which provides details about the purchase.
-
restorePurchases
final static Unit restorePurchases(ResultCallback<AdaptyProfile> callback)
To restore purchases, you have to call this method.
Should not be called before activate
- Parameters:
callback- A result containing the AdaptyProfile object.
-
updateAttribution
final static Unit updateAttribution(Object attribution, String source, ErrorCallback callback)
-
setIntegrationIdentifier
final static Unit setIntegrationIdentifier(String key, String value, ErrorCallback callback)
-
getCurrentInstallationStatus
final static Unit getCurrentInstallationStatus(ResultCallback<AdaptyInstallationStatus> callback)
-
reportTransaction
final static Unit reportTransaction(TransactionInfo transactionInfo, String variationId, ResultCallback<AdaptyProfile> callback)
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.
Should not be called before activate
- Parameters:
transactionInfo- A TransactionInfo instance, containing either a string identifier (purchase.getOrderId()) of the purchase, or an instance of the billing library Purchase class.variationId- A string identifier of variation.callback- A result containing the optional AdaptyError.
-
reportTransaction
final static Unit reportTransaction(TransactionInfo transactionInfo, ResultCallback<AdaptyProfile> callback)
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.
Should not be called before activate
- Parameters:
transactionInfo- A TransactionInfo instance, containing either a string identifier (purchase.getOrderId()) of the purchase, or an instance of the billing library Purchase class.callback- A result containing the optional AdaptyError.
-
logout
final static Unit logout(ErrorCallback callback)
You can logout the user anytime by calling this method.
Should not be called before activate
- Parameters:
callback- A result containing the optional AdaptyError.
-
setOnProfileUpdatedListener
final static Unit setOnProfileUpdatedListener(OnProfileUpdatedListener onProfileUpdatedListener)
Implement this method to receive automatic profile updates.
Should not be called before activate
-
setOnInstallationDetailsListener
final static Unit setOnInstallationDetailsListener(OnInstallationDetailsListener onInstallationDetailsListener)
-
setLogHandler
final static Unit setLogHandler(AdaptyLogHandler logHandler)
Override the default logger behavior using this method.
Can be called before activate
- Parameters:
logHandler- The function will be called for each message with the appropriate logLevel (e.g.
-
setFallback
final static Unit setFallback(FileLocation location, ErrorCallback callback)
To set fallback paywalls, use this method. 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 and there's no connection with Adapty backend (e.g. no internet connection or in the rare case when backend is down) and there's no cache on the device.
Should not be called before activate
- Parameters:
location- A location of a file with JSON representation of your paywalls/products list in the exact same format as provided by Adapty backend.callback- A result containing the optional AdaptyError.
-
setFallback
final static Unit setFallback(FileLocation location)
To set fallback paywalls, use this method. 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 and there's no connection with Adapty backend (e.g. no internet connection or in the rare case when backend is down) and there's no cache on the device.
Should not be called before activate
- Parameters:
location- A location of a file with JSON representation of your paywalls/products list in the exact same format as provided by Adapty backend.
-
logShowPaywall
final static Unit logShowPaywall(AdaptyPaywall paywall, ErrorCallback callback)
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.Should not be called before activate
- Parameters:
paywall- A AdaptyPaywall object.callback- A result containing the optional AdaptyError.
-
logShowPaywall
final static Unit logShowPaywall(AdaptyPaywall paywall)
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.Should not be called before activate
- Parameters:
paywall- A AdaptyPaywall object.
-
logShowOnboarding
final static Unit logShowOnboarding(String name, String screenName, @IntRange(from = 1) Integer screenOrder, ErrorCallback callback)
Call this method to keep track of the user’s steps while onboarding.
The onboarding stage is a very common situation in modern mobile apps. The quality of its implementation, content, and number of steps can have a rather significant influence on further user behavior, especially on his desire to become a subscriber or simply make some purchases.
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.
Should not be called before activate
- Parameters:
name- Name of your onboarding.screenName- Readable name of a particular screen as part of onboarding.screenOrder- An unsigned integer value representing the order of this screen in your onboarding sequence (it must me greater than 0).callback- A result containing the optional AdaptyError.
-
logShowOnboarding
final static Unit logShowOnboarding(String name, String screenName, @IntRange(from = 1) Integer screenOrder)
Call this method to keep track of the user’s steps while onboarding.
The onboarding stage is a very common situation in modern mobile apps. The quality of its implementation, content, and number of steps can have a rather significant influence on further user behavior, especially on his desire to become a subscriber or simply make some purchases.
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.
Should not be called before activate
- Parameters:
name- Name of your onboarding.screenName- Readable name of a particular screen as part of onboarding.screenOrder- An unsigned integer value representing the order of this screen in your onboarding sequence (it must me greater than 0).
-
getPaywallForDefaultAudience
final static Unit getPaywallForDefaultAudience(String placementId, String locale, AdaptyPlacementFetchPolicy fetchPolicy, ResultCallback<AdaptyPaywall> callback)
Fetches the paywall of the specified placement for the All Users audience.
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
getPaywallForDefaultAudiencemethod should be a last resort due to its significant drawbacks. See docs for more detailsShould not be called before activate
- Parameters:
placementId- The identifier of the desired placement.locale- This parameter is expected to be a language code composed of one or more subtags separated by the "-" character.fetchPolicy- By default SDK will try to load data from server and will return cached data in case of failure.callback- A result containing the AdaptyPaywall object.
-
getPaywallForDefaultAudience
final static Unit getPaywallForDefaultAudience(String placementId, String locale, ResultCallback<AdaptyPaywall> callback)
Fetches the paywall of the specified placement for the All Users audience.
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
getPaywallForDefaultAudiencemethod should be a last resort due to its significant drawbacks. See docs for more detailsShould not be called before activate
- Parameters:
placementId- The identifier of the desired placement.locale- This parameter is expected to be a language code composed of one or more subtags separated by the "-" character.callback- A result containing the AdaptyPaywall object.
-
getPaywallForDefaultAudience
final static Unit getPaywallForDefaultAudience(String placementId, ResultCallback<AdaptyPaywall> callback)
Fetches the paywall of the specified placement for the All Users audience.
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
getPaywallForDefaultAudiencemethod should be a last resort due to its significant drawbacks. See docs for more detailsShould not be called before activate
- Parameters:
placementId- The identifier of the desired placement.callback- A result containing the AdaptyPaywall object.
-
getOnboardingForDefaultAudience
final static Unit getOnboardingForDefaultAudience(String placementId, String locale, AdaptyPlacementFetchPolicy fetchPolicy, ResultCallback<AdaptyOnboarding> callback)
-
getOnboardingForDefaultAudience
final static Unit getOnboardingForDefaultAudience(String placementId, String locale, ResultCallback<AdaptyOnboarding> callback)
-
getOnboardingForDefaultAudience
final static Unit getOnboardingForDefaultAudience(String placementId, ResultCallback<AdaptyOnboarding> callback)
-
getLogLevel
final static AdaptyLogLevel getLogLevel()
-
setLogLevel
final static Unit setLogLevel(static AdaptyLogLevel logLevel)
-
isActivated
final static Boolean isActivated()
-
-
-
-