diff --git a/CHANGELOG.md b/CHANGELOG.md index c68887a..3105bf4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # CHANGELOG +## 0.1.4 (2024-11-04 +* Add `grantExternalEntitlements` to constructor, so we can choose whether to give entitlements to purchases verified from outside the app. + ## 0.1.3 (2024-10-31) * Verified transactions updated from outside the app are now added to purchasedProductIds. diff --git a/Sources/StoreKitHelper/PurchaseHelper.swift b/Sources/StoreKitHelper/PurchaseHelper.swift index b92c208..51c2bf6 100644 --- a/Sources/StoreKitHelper/PurchaseHelper.swift +++ b/Sources/StoreKitHelper/PurchaseHelper.swift @@ -34,9 +34,11 @@ public class PurchaseHelper: ObservableObject { /// - Parameters: /// - products: all product ids supported by the app. /// - autoFinishTransactions: call `Transaction.finish()` on verified transactions. `true` by default. Let it be unless you verify your transaction on own backend. + /// - grantExternalEntitlements: will mark product as purchased if it originated from transaction updates for verified transactions public init( products: [ProductRepresentable], - autoFinishTransactions: Bool = true + autoFinishTransactions: Bool = true, + grantExternalEntitlements: Bool = true ) { self.allProductIds = products.map { $0.getId() } self.storeKitCommunicator = StoreKitCommunicator(autoFinishTransactions: autoFinishTransactions) @@ -46,7 +48,7 @@ public class PurchaseHelper: ObservableObject { for productId in await storeKitCommunicator.listenForTransactionUpdatesAsync() { updateUI { [weak self] in guard let self else { return } - if !self.purchasedProductIds.contains(productId) { + if grantExternalEntitlements && !self.purchasedProductIds.contains(productId) { self.purchasedProductIds.append(productId) } }