russell-archer / StoreHelper

Implementing In-App Purchases with StoreKit2 in Xcode 13 - 15 using SwiftUI, Swift 5.7 - 5.9, iOS 15 - 17 and macOS 12 - 14. Also supports tvOS and visionOS.
MIT License
422 stars 49 forks source link

`.onReceive(storeHelper.$purchasedProducts)` doesn't seem to fire when a user finishes a purchase #79

Closed tanin47 closed 4 months ago

tanin47 commented 4 months ago

I can't use onChange because my app doesn't target MacOS 14.0.

Is there a gotcha I'm not aware of?

My code looks like the example:

let storeHelper = StoreHelper()

...
.task { storeHelper.start() }
.onReceive(storeHelper.$purchasedProducts) {
  print("Received")
}

If there's nothing obvious, I can provide a full proof of concept.

tanin47 commented 4 months ago

It's because we were using Button and invoke purchase by ourselves. My friend has found that the transaction was unfinished. We've switched to PurchaseButton and it works.

russell-archer commented 4 months ago

Sorry for the delay in responding - been on vacation. Glad you figured it all out!