Android Adapty SDK 3.10.0 迁移指南

Adapty SDK 3.10.0 是一个主要版本,带来了一些改进,但可能需要您执行一些迁移步骤:

  1. AdaptyUiPersonalizedOfferResolver 已被移除。如果您正在使用它,请在 onAwaitingPurchaseParams 回调中传入。
  2. 更新付费墙编辑工具付费墙的 onAwaitingSubscriptionUpdateParams 方法签名。

更新购买参数回调

onAwaitingSubscriptionUpdateParams 方法已重命名为 onAwaitingPurchaseParams,现在使用 AdaptyPurchaseParameters 代替 AdaptySubscriptionUpdateParameters。这使您可以指定订阅替换参数(跨级别升降级)并指示价格是否为个性化价格(了解更多),以及其他购买参数。

- override fun onAwaitingSubscriptionUpdateParams(
-     product: AdaptyPaywallProduct,
-     context: Context,
-     onSubscriptionUpdateParamsReceived: SubscriptionUpdateParamsCallback,
- ) {
-     onSubscriptionUpdateParamsReceived(AdaptySubscriptionUpdateParameters(...))
- }

+ override fun onAwaitingPurchaseParams(
+     product: AdaptyPaywallProduct,
+     context: Context,
+     onPurchaseParamsReceived: AdaptyUiEventListener.PurchaseParamsCallback,
+ ): AdaptyUiEventListener.PurchaseParamsCallback.IveBeenInvoked {
+     onPurchaseParamsReceived(
+         AdaptyPurchaseParameters.Builder()
+             .withSubscriptionUpdateParams(AdaptySubscriptionUpdateParameters(...)) 
+             .withOfferPersonalized(true) 
+             .build()
+     )
+     return AdaptyUiEventListener.PurchaseParamsCallback.IveBeenInvoked
+ }

如果不需要额外的参数,您可以直接使用:

+ override fun onAwaitingPurchaseParams(
    product: AdaptyPaywallProduct,
    context: Context,
    onPurchaseParamsReceived: AdaptyUiEventListener.PurchaseParamsCallback,
): AdaptyUiEventListener.PurchaseParamsCallback.IveBeenInvoked {
    onPurchaseParamsReceived(AdaptyPurchaseParameters.Empty)
    return AdaptyUiEventListener.PurchaseParamsCallback.IveBeenInvoked
}