Skip to content

Commit

Permalink
Fix iOS StoreProduct description & price (#108)
Browse files Browse the repository at this point in the history
* Fixes a ClassCastException in Price.ios.kt.
* Renames StoreProduct.description to localizedDescription to avoid shadowing the built-in ObjC description member.
  • Loading branch information
JayShortway authored Jun 24, 2024
1 parent 93d048f commit ee0d40b
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import com.revenuecat.purchases.kmp.models.StoreProductDiscount
import com.revenuecat.purchases.kmp.models.SubscriptionOption
import com.revenuecat.purchases.kmp.models.SubscriptionOptions
import com.revenuecat.purchases.kmp.models.defaultOption
import com.revenuecat.purchases.kmp.models.description
import com.revenuecat.purchases.kmp.models.discounts
import com.revenuecat.purchases.kmp.models.id
import com.revenuecat.purchases.kmp.models.introductoryDiscount
import com.revenuecat.purchases.kmp.models.localizedDescription
import com.revenuecat.purchases.kmp.models.period
import com.revenuecat.purchases.kmp.models.presentedOfferingContext
import com.revenuecat.purchases.kmp.models.price
Expand All @@ -30,7 +30,7 @@ private class StoreProductAPI {
val type: ProductType = type
val price: Price = price
val title: String = title
val description: String? = description
val description: String? = localizedDescription
val period: Period? = period
val subscriptionOptions: SubscriptionOptions? = subscriptionOptions
val defaultOption: SubscriptionOption? = defaultOption
Expand Down
2 changes: 1 addition & 1 deletion core/api/core.api
Original file line number Diff line number Diff line change
Expand Up @@ -514,10 +514,10 @@ public final class com/revenuecat/purchases/kmp/models/StoreProductDiscount_andr

public final class com/revenuecat/purchases/kmp/models/StoreProduct_androidKt {
public static final fun getDefaultOption (Lcom/revenuecat/purchases/kmp/models/StoreProduct;)Lcom/revenuecat/purchases/models/SubscriptionOption;
public static final fun getDescription (Lcom/revenuecat/purchases/kmp/models/StoreProduct;)Ljava/lang/String;
public static final fun getDiscounts (Lcom/revenuecat/purchases/kmp/models/StoreProduct;)Ljava/util/List;
public static final fun getId (Lcom/revenuecat/purchases/kmp/models/StoreProduct;)Ljava/lang/String;
public static final fun getIntroductoryDiscount (Lcom/revenuecat/purchases/kmp/models/StoreProduct;)Lcom/revenuecat/purchases/kmp/models/StoreProductDiscount;
public static final fun getLocalizedDescription (Lcom/revenuecat/purchases/kmp/models/StoreProduct;)Ljava/lang/String;
public static final fun getPeriod (Lcom/revenuecat/purchases/kmp/models/StoreProduct;)Lcom/revenuecat/purchases/models/Period;
public static final fun getPresentedOfferingContext (Lcom/revenuecat/purchases/kmp/models/StoreProduct;)Lcom/revenuecat/purchases/PresentedOfferingContext;
public static final fun getPrice (Lcom/revenuecat/purchases/kmp/models/StoreProduct;)Lcom/revenuecat/purchases/models/Price;
Expand Down
4 changes: 2 additions & 2 deletions core/api/core.klib.api
Original file line number Diff line number Diff line change
Expand Up @@ -548,8 +548,6 @@ final val com.revenuecat.purchases.kmp.models/billingPeriod // com.revenuecat.pu
final fun (com.revenuecat.purchases.kmp.models/SubscriptionOption).<get-billingPeriod>(): cocoapods.PurchasesHybridCommon/RCSubscriptionPeriod? // com.revenuecat.purchases.kmp.models/billingPeriod.<get-billingPeriod>|<get-billingPeriod>@com.revenuecat.purchases.kmp.models.SubscriptionOption(){}[0]
final val com.revenuecat.purchases.kmp.models/defaultOption // com.revenuecat.purchases.kmp.models/defaultOption|@cocoapods.PurchasesHybridCommon.RCStoreProduct{}defaultOption[0]
final fun (cocoapods.PurchasesHybridCommon/RCStoreProduct).<get-defaultOption>(): com.revenuecat.purchases.kmp.models/SubscriptionOption? // com.revenuecat.purchases.kmp.models/defaultOption.<get-defaultOption>|<get-defaultOption>@cocoapods.PurchasesHybridCommon.RCStoreProduct(){}[0]
final val com.revenuecat.purchases.kmp.models/description // com.revenuecat.purchases.kmp.models/description|@cocoapods.PurchasesHybridCommon.RCStoreProduct{}description[0]
final fun (cocoapods.PurchasesHybridCommon/RCStoreProduct).<get-description>(): kotlin/String? // com.revenuecat.purchases.kmp.models/description.<get-description>|<get-description>@cocoapods.PurchasesHybridCommon.RCStoreProduct(){}[0]
final val com.revenuecat.purchases.kmp.models/discount // com.revenuecat.purchases.kmp.models/discount|@cocoapods.PurchasesHybridCommon.RCPromotionalOffer{}discount[0]
final fun (cocoapods.PurchasesHybridCommon/RCPromotionalOffer).<get-discount>(): cocoapods.PurchasesHybridCommon/RCStoreProductDiscount // com.revenuecat.purchases.kmp.models/discount.<get-discount>|<get-discount>@cocoapods.PurchasesHybridCommon.RCPromotionalOffer(){}[0]
final val com.revenuecat.purchases.kmp.models/discounts // com.revenuecat.purchases.kmp.models/discounts|@cocoapods.PurchasesHybridCommon.RCStoreProduct{}discounts[0]
Expand All @@ -570,6 +568,8 @@ final val com.revenuecat.purchases.kmp.models/isBasePlan // com.revenuecat.purch
final fun (com.revenuecat.purchases.kmp.models/SubscriptionOption).<get-isBasePlan>(): kotlin/Boolean // com.revenuecat.purchases.kmp.models/isBasePlan.<get-isBasePlan>|<get-isBasePlan>@com.revenuecat.purchases.kmp.models.SubscriptionOption(){}[0]
final val com.revenuecat.purchases.kmp.models/isPrepaid // com.revenuecat.purchases.kmp.models/isPrepaid|@com.revenuecat.purchases.kmp.models.SubscriptionOption{}isPrepaid[0]
final fun (com.revenuecat.purchases.kmp.models/SubscriptionOption).<get-isPrepaid>(): kotlin/Boolean // com.revenuecat.purchases.kmp.models/isPrepaid.<get-isPrepaid>|<get-isPrepaid>@com.revenuecat.purchases.kmp.models.SubscriptionOption(){}[0]
final val com.revenuecat.purchases.kmp.models/localizedDescription // com.revenuecat.purchases.kmp.models/localizedDescription|@cocoapods.PurchasesHybridCommon.RCStoreProduct{}localizedDescription[0]
final fun (cocoapods.PurchasesHybridCommon/RCStoreProduct).<get-localizedDescription>(): kotlin/String? // com.revenuecat.purchases.kmp.models/localizedDescription.<get-localizedDescription>|<get-localizedDescription>@cocoapods.PurchasesHybridCommon.RCStoreProduct(){}[0]
final val com.revenuecat.purchases.kmp.models/numberOfPeriods // com.revenuecat.purchases.kmp.models/numberOfPeriods|@cocoapods.PurchasesHybridCommon.RCStoreProductDiscount{}numberOfPeriods[0]
final fun (cocoapods.PurchasesHybridCommon/RCStoreProductDiscount).<get-numberOfPeriods>(): kotlin/Long // com.revenuecat.purchases.kmp.models/numberOfPeriods.<get-numberOfPeriods>|<get-numberOfPeriods>@cocoapods.PurchasesHybridCommon.RCStoreProductDiscount(){}[0]
final val com.revenuecat.purchases.kmp.models/offerIdentifier // com.revenuecat.purchases.kmp.models/offerIdentifier|@cocoapods.PurchasesHybridCommon.RCStoreProductDiscount{}offerIdentifier[0]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public actual val StoreProduct.price: Price
get() = price
public actual val StoreProduct.title: String
get() = title
public actual val StoreProduct.description: String?
public actual val StoreProduct.localizedDescription: String?
get() = description
public actual val StoreProduct.period: Period?
get() = period
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public expect val StoreProduct.title: String
/**
* The description of the product.
*/
public expect val StoreProduct.description: String?
public expect val StoreProduct.localizedDescription: String?

/**
* Subscription period.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,5 @@ internal fun RCStoreProductDiscount.currencyCodeOrUsd(): String =

private fun NSNumberFormatter?.amountDecimalOrDefault(localizedPrice: String, defaultValue: String): NSDecimalNumber =
this?.numberFromString(localizedPrice)
?.let { it as NSDecimalNumber }
?.let { NSDecimalNumber.decimalNumberWithString(it.stringValue) }
?: NSDecimalNumber.decimalNumberWithString(defaultValue)
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public actual val StoreProduct.price: Price
get() = toPrice()
public actual val StoreProduct.title: String
get() = localizedTitle()
public actual val StoreProduct.description: String?
public actual val StoreProduct.localizedDescription: String?
get() = localizedDescription()
public actual val StoreProduct.period: Period?
get() = subscriptionPeriod()
Expand Down

0 comments on commit ee0d40b

Please sign in to comment.