Solved

Migrating to 6.0 - freeTrialPeriod and subscriptionPeriod not found

  • 25 September 2023
  • 1 reply
  • 45 views

Badge +2

Hello,

 

I’m struggling with the RevenueCat update from 5.x to 6.4.0 on Android.

 

I have currently a method to load the weekly subscription, however product doesn’t have subscriptionPeriod any longer.
 

fun loadWeeklyProduct(onPackageLoaded: (Package?) -> Unit) {
Purchases.sharedInstance.getOfferingsWith(
{ error ->
// An error occurred
}) { offerings ->
val annualProduct = offerings.current?.availablePackages?.firstOrNull { item ->
item.product.subscriptionPeriod == "P1W"
}
onPackageLoaded(annualProduct)
}
}

And with this other method I would check if they still are eligible for Trial. Sadly product also no longer has any freeTrialPeriod.

 

private fun fillTrialOrNormal(it: Package) {
val hasFreeTrial = !it.product.freeTrialPeriod.isNullOrEmpty()
Utilities().checkTrialUsedUp(it.product.sku, hasFreeTrial) { trialUsedUp ->
var title = ""
var header = ""
if (trialUsedUp) {
title = "${it.product.price} / Year"
header = getString(R.string.upgrade_to_premium)
binding.premiumTextId.text = header
} else {
title = "Start Your 3 Days Free Trial,\nThen ${it.product.price} / Year"
}
binding.trialPurchaseButtonId.text = title
binding.trialPurchaseButtonId.isEnabled = true
}
}

 

I couldn’t find anything about this on the migration document.  I would really appreciate any hints how to achieve this.  

 

Many Thanks,

Houman

icon

Best answer by Ryan Glanz 27 September 2023, 17:13

View original

1 reply

Userlevel 3
Badge +8

Hi Houman,

Here’s our StoreProduct doc, which has a period property, which is now the subscriptionPeriod.

The StoreProduct also has a subscriptionOptions property, which has some relevant properties for trials, etc.

Reply