From 4a731292221310aa225a62002bb3f90ee5cb273e Mon Sep 17 00:00:00 2001 From: cervenkovab Date: Sat, 18 Nov 2023 19:57:46 +0100 Subject: [PATCH 1/2] feat: add currency regarding the new API --- ios/IapSerializationUtils.swift | 3 ++- src/types/appleSk2.ts | 7 +++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/ios/IapSerializationUtils.swift b/ios/IapSerializationUtils.swift index 936391493..98e84ca6c 100644 --- a/ios/IapSerializationUtils.swift +++ b/ios/IapSerializationUtils.swift @@ -19,7 +19,8 @@ func serialize(_ p: Product) -> [String: Any?] { "jsonRepresentation": serializeDebug(p.jsonRepresentation), "price": p.price, "subscription": serialize(p.subscription), - "type": serialize(p.type) + "type": serialize(p.type), + "currency": p.priceFormatStyle.currencyCode ] } diff --git a/src/types/appleSk2.ts b/src/types/appleSk2.ts index 466792a1b..4b3c57350 100644 --- a/src/types/appleSk2.ts +++ b/src/types/appleSk2.ts @@ -36,6 +36,7 @@ export type SubscriptionInfo = { export type RefundRequestStatus = 'success' | 'userCancelled'; export type ProductSk2 = { + currency: string; description: string; displayName: string; displayPrice: string; @@ -51,6 +52,7 @@ export const productSk2Map = ({ description, displayName, price, + currency, displayPrice, }: ProductSk2): ProductIOS => { const prod: ProductIOS = { @@ -60,7 +62,7 @@ export const productSk2Map = ({ type: 'iap', price: String(price), localizedPrice: displayPrice, - currency: '', // Not available on new API, use localizedPrice instead + currency }; return prod; }; @@ -70,6 +72,7 @@ export const subscriptionSk2Map = ({ description, displayName, price, + currency, displayPrice, subscription, }: ProductSk2): SubscriptionIOS => { @@ -81,7 +84,7 @@ export const subscriptionSk2Map = ({ type: 'subs', price: String(price), localizedPrice: displayPrice, - currency: '', // Not available on new API, use localizedPrice instead + currency, subscriptionPeriodNumberIOS: `${subscription?.subscriptionPeriod?.value}`, subscriptionPeriodUnitIOS: subscription?.subscriptionPeriod?.unit.toUpperCase() as SubscriptionIosPeriod, From ca2e27fe22f588ff51915a3801a9d555839c366e Mon Sep 17 00:00:00 2001 From: cervenkovab Date: Sat, 18 Nov 2023 20:49:03 +0100 Subject: [PATCH 2/2] fix swift lint --- ios/RNIapIosSk2.swift | 4 ---- 1 file changed, 4 deletions(-) diff --git a/ios/RNIapIosSk2.swift b/ios/RNIapIosSk2.swift index 35a092dc1..15003f891 100644 --- a/ios/RNIapIosSk2.swift +++ b/ios/RNIapIosSk2.swift @@ -277,10 +277,6 @@ class RNIapIosSk2: RCTEventEmitter, Sk2Delegate { delegate.stopObserving() } - override func addListener(_ eventName: String?) { - super.addListener(eventName) - } - /** "iap-transaction-updated" is unique to Sk2. "iap-promoted-product" is only avaiable on Sk1