Adapty Android SDK'yı v3.3'e Taşıma
Adapty SDK 3.3.0, bazı iyileştirmeler getiren önemli bir sürümdür; ancak bu iyileştirmeler sizin tarafınızdan bazı geçiş adımları gerektirebilir.
- Paywall Builder ile oluşturulmayan paywall’larda satın alma işlemlerini nasıl ele aldığınızı güncelleyin.
USER_CANCELEDvePENDING_PURCHASEhata kodlarını işlemeyi bırakın. İptal edilen bir satın alma artık hata olarak kabul edilmez ve hata olmayan satın alma sonuçlarında görünecektir. - Paywall Builder ile oluşturulan paywall’lar için
onPurchaseCanceledveonPurchaseSuccessolaylarını yenionPurchaseFinishedolayıyla değiştirin. Bu değişiklik aynı nedenle yapılmaktadır: iptal edilen satın almalar artık hata olarak değerlendirilmez ve hata olmayan satın alma sonuçlarına dahil edilir. - Paywall Builder paywallları için
onAwaitingSubscriptionUpdateParamsmetot imzasını değiştirin. - Dosya URI’sini doğrudan geçiriyorsanız yedek paywall sağlamak için kullanılan metodu güncelleyin.
- Adjust, AirBridge, Amplitude, AppMetrica, Appsflyer, Branch, Facebook Ads, Firebase ve Google Analytics, Mixpanel, OneSignal, Pushwoosh için entegrasyon yapılandırmalarını güncelleyin.
Satın alma işlemini güncelleme
Daha önce iptal edilen ve beklemedeki satın almalar hata olarak değerlendirilir ve sırasıyla USER_CANCELED ve PENDING_PURCHASE kodları döndürülürdü.
Artık iptal edilen, başarılı ve beklemedeki satın almaları belirtmek için yeni bir AdaptyPurchaseResult sınıfı kullanılmaktadır. Satın alma kodunu aşağıdaki şekilde güncelleyin:
Adapty.makePurchase(activity, product) { result ->
when (result) {
is AdaptyResult.Success -> {
- val info = result.value
- val profile = info?.profile
-
- if (profile?.accessLevels?.get("YOUR_ACCESS_LEVEL")?.isActive == true) {
- // Grant access to the paid features
- }
+ when (val purchaseResult = result.value) {
+ is AdaptyPurchaseResult.Success -> {
+ val profile = purchaseResult.profile
+ if (profile.accessLevels["YOUR_ACCESS_LEVEL"]?.isActive == true) {
+ // Grant access to the paid features
+ }
+ }
+
+ is AdaptyPurchaseResult.UserCanceled -> {
+ // Handle the case where the user canceled the purchase
+ }
+
+ is AdaptyPurchaseResult.Pending -> {
+ // Handle deferred purchases (e.g., the user will pay offline with cash
+ }
+ }
}
is AdaptyResult.Error -> {
val error = result.error
// Handle the error
}
}
}
Tam kod örneği için Mobil uygulamada satın alma yapma sayfasına göz atın.
Paywall Builder satın alma olaylarını değiştirme
onPurchaseFinishedolayı ekleyin:+ public override fun onPurchaseFinished( + purchaseResult: AdaptyPurchaseResult, + product: AdaptyPaywallProduct, + context: Context, + ) { + when (purchaseResult) { + is AdaptyPurchaseResult.Success -> { + // Grant access to the paid features + } + is AdaptyPurchaseResult.UserCanceled -> { + // Handle the case where the user canceled the purchase + } + is AdaptyPurchaseResult.Pending -> { + // Handle deferred purchases (e.g., the user will pay offline with cash) + } + } + }
Tam kod örneği için Başarılı, iptal edilen veya beklemedeki satın alma bölümüne ve olay açıklamasına bakın.
-
onPurchaseCancelledolayının işlenmesini kaldırın:- public override fun onPurchaseCanceled( - product: AdaptyPaywallProduct, - context: Context, - ) {} -
onPurchaseSuccessifadesini kaldırın:- public override fun onPurchaseSuccess( - profile: AdaptyProfile?, - product: AdaptyPaywallProduct, - context: Context, - ) { - // Your logic on successful purchase - }
onAwaitingSubscriptionUpdateParams metodunun imzasını değiştirin
Artık başka bir abonelik aktifken yeni bir abonelik satın alınırsa, yeni aboneliğin mevcut aktif aboneliğin yerini alması gerekiyorsa onSubscriptionUpdateParamsReceived(AdaptySubscriptionUpdateParameters...)) çağırın; aktif aboneliğin yerinde kalması ve yeni aboneliğin ayrı olarak eklenmesi gerekiyorsa onSubscriptionUpdateParamsReceived(null) çağırın:
- public override fun onAwaitingSubscriptionUpdateParams(
- product: AdaptyPaywallProduct,
- context: Context,
- ): AdaptySubscriptionUpdateParameters? {
- return AdaptySubscriptionUpdateParameters(...)
- }
+ public override fun onAwaitingSubscriptionUpdateParams(
+ product: AdaptyPaywallProduct,
+ context: Context,
+ onSubscriptionUpdateParamsReceived: SubscriptionUpdateParamsCallback,
+ ) {
+ onSubscriptionUpdateParamsReceived(AdaptySubscriptionUpdateParameters(...))
+ }
Yükseltme aboneliği doküman bölümüne bakarak son kod örneğini inceleyebilirsiniz.
Yedek paywall’ları güncelleme
Yedek paywall’ları sağlamak için dosya URI’si kullanıyorsanız, bunu aşağıdaki şekilde güncelleyin:
Üçüncü taraf entegrasyon SDK yapılandırmasını güncelleme
Adapty Android SDK 3.3.0 ve sonraki sürümlerle entegrasyonların düzgün çalışmasını sağlamak için aşağıdaki bölümlerde açıklandığı şekilde entegrasyon SDK yapılandırmalarınızı güncelleyin.
Adjust
Mobil uygulama kodunuzu aşağıda gösterildiği gibi güncelleyin. Tam kod örneği için Adjust entegrasyonu için SDK yapılandırması sayfasına bakın.
AirBridge
Mobil uygulama kodunuzu aşağıda gösterildiği gibi güncelleyin. Tam kod örneği için AirBridge entegrasyonu için SDK yapılandırması bölümüne bakın.
Airbridge.getDeviceInfo().getUUID(object: AirbridgeCallback.SimpleCallback<String>() {
override fun onSuccess(result: String) {
- val params = AdaptyProfileParameters.Builder()
- .withAirbridgeDeviceId(result)
- .build()
- Adapty.updateProfile(params) { error ->
- if (error != null) {
- // Handle the error
- }
- }
+ Adapty.setIntegrationIdentifier("airbridge_device_id", result) { error ->
+ if (error != null) {
+ // Handle the error
+ }
+ }
}
override fun onFailure(throwable: Throwable) {
}
})
Amplitude
Mobil uygulama kodunuzu aşağıda gösterildiği gibi güncelleyin. Tam kod örneği için Amplitude entegrasyonu için SDK yapılandırması bölümüne bakın.
// For Amplitude maintenance SDK (obsolete)
val amplitude = Amplitude.getInstance()
val amplitudeDeviceId = amplitude.getDeviceId()
val amplitudeUserId = amplitude.getUserId()
//for actual Amplitude Kotlin SDK
val amplitude = Amplitude(
Configuration(
apiKey = AMPLITUDE_API_KEY,
context = applicationContext
)
)
val amplitudeDeviceId = amplitude.store.deviceId
val amplitudeUserId = amplitude.store.userId
//
- val params = AdaptyProfileParameters.Builder()
- .withAmplitudeDeviceId(amplitudeDeviceId)
- .withAmplitudeUserId(amplitudeUserId)
- .build()
- Adapty.updateProfile(params) { error ->
- if (error != null) {
- // Handle the error
- }
- }
+ Adapty.setIntegrationIdentifier("amplitude_user_id", amplitudeUserId) { error ->
+ if (error != null) {
+ // Handle the error
+ }
+ }
+ Adapty.setIntegrationIdentifier("amplitude_device_id", amplitudeDeviceId) { error ->
+ if (error != null) {
+ // Handle the error
+ }
+ }
AppMetrica
Mobil uygulama kodunuzu aşağıda gösterildiği şekilde güncelleyin. Tam kod örneği için AppMetrica entegrasyonu için SDK yapılandırması sayfasına bakın.
val startupParamsCallback = object: StartupParamsCallback {
override fun onReceive(result: StartupParamsCallback.Result?) {
val deviceId = result?.deviceId ?: return
- val params = AdaptyProfileParameters.Builder()
- .withAppmetricaDeviceId(deviceId)
- .withAppmetricaProfileId("YOUR_ADAPTY_CUSTOMER_USER_ID")
- .build()
- Adapty.updateProfile(params) { error ->
- if (error != null) {
- // Handle the error
- }
- }
+ Adapty.setIntegrationIdentifier("appmetrica_device_id", deviceId) { error ->
+ if (error != null) {
+ // Handle the error
+ }
+ }
+
+ Adapty.setIntegrationIdentifier("appmetrica_profile_id", "YOUR_ADAPTY_CUSTOMER_USER_ID") { error ->
+ if (error != null) {
+ // Handle the error
+ }
+ }
}
override fun onRequestError(
reason: StartupParamsCallback.Reason,
result: StartupParamsCallback.Result?
) {
// Handle the error
}
}
AppMetrica.requestStartupParams(context, startupParamsCallback, listOf(StartupParamsCallback.APPMETRICA_DEVICE_ID))
AppsFlyer
Mobil uygulama kodunuzu aşağıda gösterildiği şekilde güncelleyin. Tam kod örneği için AppsFlyer entegrasyonu için SDK yapılandırması sayfasına bakın.
val conversionListener: AppsFlyerConversionListener = object : AppsFlyerConversionListener {
override fun onConversionDataSuccess(conversionData: Map<String, Any>) {
- Adapty.updateAttribution(
- conversionData,
- AdaptyAttributionSource.APPSFLYER,
- AppsFlyerLib.getInstance().getAppsFlyerUID(context)
- ) { error ->
- if (error != null) {
- // Handle the error
- }
- }
+ val uid = AppsFlyerLib.getInstance().getAppsFlyerUID(context)
+ Adapty.setIntegrationIdentifier("appsflyer_id", uid) { error ->
+ if (error != null) {
+ // Handle the error
+ }
+ }
+ Adapty.updateAttribution(conversionData, "appsflyer") { error ->
+ if (error != null) {
+ // Handle the error
+ }
+ }
}
}
Branch
Mobil uygulama kodunuzu aşağıda gösterildiği şekilde güncelleyin. Tam kod örneği için Branch entegrasyonu için SDK yapılandırması bölümüne bakın.
// Login and update attribution
Branch.getAutoInstance(this)
.setIdentity("YOUR_USER_ID") { referringParams, error ->
referringParams?.let { data ->
- Adapty.updateAttribution(data, AdaptyAttributionSource.BRANCH) { error ->
- if (error != null) {
- // Handle the error
- }
- }
+ Adapty.updateAttribution(data, "branch") { error ->
+ if (error != null) {
+ // Handle the error
+ }
+ }
}
}
// Logout
Branch.getAutoInstance(context).logout()
Facebook Ads
Mobil uygulama kodunuzu aşağıda gösterildiği gibi güncelleyin. Tam kod örneği için Facebook Ads entegrasyonu için SDK yapılandırması bölümüne bakın.
- val builder = AdaptyProfileParameters.Builder()
- .withFacebookAnonymousId(AppEventsLogger.getAnonymousAppDeviceGUID(context))
-
- Adapty.updateProfile(builder.build()) { error ->
- if (error != null) {
- // Handle the error
- }
- }
+ Adapty.setIntegrationIdentifier(
+ "facebook_anonymous_id",
+ AppEventsLogger.getAnonymousAppDeviceGUID(context)
+ ) { error ->
+ if (error != null) {
+ // Handle the error
+ }
+ }
Firebase ve Google Analytics
Aşağıda gösterildiği gibi mobil uygulama kodunuzu güncelleyin. Tam kod örneği için Firebase ve Google Analytics entegrasyonu için SDK yapılandırması sayfasına bakın.
Mixpanel
Mobil uygulama kodunuzu aşağıda gösterildiği gibi güncelleyin. Tam kod örneği için Mixpanel entegrasyonuna yönelik SDK yapılandırması bölümüne bakın.
- val params = AdaptyProfileParameters.Builder()
- .withMixpanelUserId(mixpanelAPI.distinctId)
- .build()
-
- Adapty.updateProfile(params) { error ->
- if (error != null) {
- // Handle the error
- }
- }
+ Adapty.setIntegrationIdentifier("mixpanel_user_id", mixpanelAPI.distinctId) { error ->
+ if (error != null) {
+ // Handle the error
+ }
+ }
OneSignal
Mobil uygulama kodunuzu aşağıda gösterildiği gibi güncelleyin. Tam kod örneği için OneSignal entegrasyonunda SDK yapılandırması bölümüne bakın.
Pushwoosh
Mobil uygulama kodunuzu aşağıda gösterildiği gibi güncelleyin. Tam kod örneği için Pushwoosh entegrasyonu için SDK yapılandırmasına bakın.