Skip to content
This repository was archived by the owner on Oct 16, 2025. It is now read-only.

Commit 5b46e56

Browse files
committed
fix: Use DiscountOfferInputIOS for subscription offers
Changed from SubscriptionOfferIOS to DiscountOfferInputIOS which is the correct type for promotional offers in subscription requests.
1 parent 6c5df56 commit 5b46e56

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

Sources/OpenIapModule+ObjC.swift

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -146,13 +146,18 @@ import StoreKit
146146
Task {
147147
do {
148148
// For subscription request, type must be .subs
149-
let subscriptionOffer: SubscriptionOfferIOS? = if let offer = offer {
150-
SubscriptionOfferIOS(
151-
id: offer["id"] as? String,
152-
keyIdentifier: offer["keyIdentifier"] as? String,
153-
nonce: (offer["nonce"] as? String).flatMap { UUID(uuidString: $0) },
154-
signature: offer["signature"] as? String,
155-
timestamp: offer["timestamp"] as? Int64 ?? 0
149+
let discountOffer: DiscountOfferInputIOS? = if let offer = offer,
150+
let identifier = offer["identifier"] as? String,
151+
let keyIdentifier = offer["keyIdentifier"] as? String,
152+
let nonce = offer["nonce"] as? String,
153+
let signature = offer["signature"] as? String,
154+
let timestamp = offer["timestamp"] as? Double {
155+
DiscountOfferInputIOS(
156+
identifier: identifier,
157+
keyIdentifier: keyIdentifier,
158+
nonce: nonce,
159+
signature: signature,
160+
timestamp: timestamp
156161
)
157162
} else {
158163
nil
@@ -162,7 +167,7 @@ import StoreKit
162167
andDangerouslyFinishTransactionAutomatically: nil,
163168
appAccountToken: nil,
164169
sku: sku,
165-
withOffer: subscriptionOffer
170+
withOffer: discountOffer
166171
)
167172
let props = RequestPurchaseProps(
168173
request: .subscription(

0 commit comments

Comments
 (0)