Migrar el SDK de Android de Adapty a la versión 3.0
Adapty SDK v3.0 introduces significant changes. This document outlines the key modifications to help you upgrade from v2.x to v3.0. We’ve made every effort to ensure backward compatibility, but some changes may require updates to your codebase.
Renaming Paywalls to Placements
In v3.0, we’ve renamed “paywalls” to “placements” throughout the SDK. This change reflects the concept that a “placement” is a specific location in your app where a paywall can be displayed. Here’s a summary of the renaming:
Before (v2.x)
After (v3.0)
getPaywalls()
getPlacements()
Paywall
Placement
paywallId
placementId
paywallVariationId
placementVariationId
Changes to AdaptyPaywall
AdaptyPaywall in v3.0 contains the following properties:
Property
Type
Description
placementId
String
The ID of the placement in Adapty
variationId
String
The ID of the variation in the A/B test
revision
Int
The revision of the paywall
onboardingScreens
List<AdaptyOnboardingScreenContent>
The onboarding screens for the paywall
remoteConfig
AdaptyRemoteConfig?
The remote config for the paywall
products
List<AdaptyPaywallProduct>
The products associated with the paywall
Start Using Adapty Android SDK v3.0
Starting with v3.0, we recommend initializing the Adapty Android SDK in the Application.onCreate() method. This ensures the SDK is ready to use when your app launches.
The configuration builder was updated to allow for a more flexible setup. The new builder accepts an appKey parameter, which is your Adapty API key. The old builder accepted a apiKey parameter.
Adapty.getPaywall(placementId, locale, loadTimeout) { result -> when (result) { is AdaptyResult.Success -> { val paywall = result.value // use paywall } is AdaptyResult.Error -> { val error = result.error // handle the error } }}
Adapty.getPaywall(id, locale, fetchPolicy, loadTimeout) { result -> when (result) { is AdaptyResult.Success -> { val paywall = result.value // use paywall } is AdaptyResult.Error -> { val error = result.error // handle the error } }}
The fetchPolicy parameter has been removed from getPaywall. This parameter previously controlled whether the SDK fetched fresh data from the server or used a cached version. You can now control this via the configuration builder.
Retrieving paywall products
Adapty.getPaywallProducts(paywall) { result -> when (result) { is AdaptyResult.Success -> { val products = result.value // use the products } is AdaptyResult.Error -> { val error = result.error // handle the error } }}
Adapty.getPaywallProducts(paywall) { result -> when (result) { is AdaptyResult.Success -> { val products = result.value // use the products } is AdaptyResult.Error -> { val error = result.error // handle the error } }}
Logging paywall display
Adapty.logShowPaywall(paywall)
Adapty.logShowPaywall(paywall)
Changes to AdaptyProfile
In v3.0, we’ve updated AdaptyProfile. The customAttributes property is now included in the AdaptyProfile.CustomerUser object rather than directly in the profile.
val profile: AdaptyProfileval customAttributes = profile.customerUser?.customAttributes
val profile: AdaptyProfileval customAttributes = profile.customAttributes
Changes to AdaptyPaywallProduct
In v3.0, we’ve updated AdaptyPaywallProduct. The variationId property has been removed and the paywallVariationId property has been renamed to variationId.
val product: AdaptyPaywallProductval variationId = product.variationId
val product: AdaptyPaywallProductval variationId = product.paywallVariationId
Changes to AdaptySubscriptionUpdateParameters
In v3.0, we’ve updated AdaptySubscriptionUpdateParameters. The replacementMode property has been renamed to prorationMode.
val params = AdaptySubscriptionUpdateParameters( oldSubVendorProductId, prorationMode)
val params = AdaptySubscriptionUpdateParameters( oldSubVendorProductId, replacementMode)
Changes to AdaptyPurchasedInfo
In v3.0, we’ve updated AdaptyPurchasedInfo. The response now includes the profile and, optionally, the purchase property.
Adapty.makePurchase(activity, product, subscriptionUpdateParams, isOfferPersonalized) { result -> when (result) { is AdaptyResult.Success -> { val profile = result.value.profile val purchase = result.value.purchase } is AdaptyResult.Error -> { val error = result.error // handle the error } }}
Adapty.makePurchase(activity, product, subscriptionUpdateParams, isOfferPersonalized) { result -> when (result) { is AdaptyResult.Success -> { val profile = result.value.profile } is AdaptyResult.Error -> { val error = result.error // handle the error } }}
Adapty SDK v3.0 trae soporte para el nuevo e innovador Adapty Paywall Builder, la nueva versión de la herramienta no-code y fácil de usar para crear paywalls. Con su máxima flexibilidad y ricas capacidades de diseño, tus paywalls serán más efectivos y rentables.
Los SDKs de Adapty se distribuyen como un BoM (Bill of Materials), lo que garantiza que las versiones del SDK de Adapty y del SDK de AdaptyUI en tu app sean siempre consistentes.
Para migrar a v3.0, actualiza tu código de la siguiente manera: