Skip to content

Commit

Permalink
Merge branch 'release/0.1.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
mvojtkovszky committed Nov 4, 2024
2 parents 6f552ff + 6e5aef5 commit 12a70b4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.

Expand Down
6 changes: 4 additions & 2 deletions Sources/StoreKitHelper/PurchaseHelper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
}
}
Expand Down

0 comments on commit 12a70b4

Please sign in to comment.