Comments (5)
Sorry for the delay in replying - been on a short vacation!
Re your issue, I'm certain that StoreHelper does (or did) pick up subscription cancellations correctly. It's possible I've done something to break it, but I'll take a look and let you know.
from storehelper.
Yes, you're right. Cancellations are not being correctly picked up. I'll put out a fix asap!
from storehelper.
Hi Russel, thanks for picking it up. Sorry to bother you post-holiday :). Generally speaking, I've been finding using currentEntitlements() with requestProductsFromAppStore() to give a pretty reliable result. Eventually, things are updated or timed out in such a way that the Product returned is nil once expired. Hope that helps a bit.
Thanks,
--Alex
from storehelper.
I've added a few things to help with the situation where subscriptions are renewed or expire when the app's not running.
See AppStoreHelper.paymentQueue(_:updatedTransactions:)
and StoreHelper.handleStoreKit1Transactions(productId:status:transaction:)
.
From the research I've done, it looks like when using Xcode StoreKit Testing and Sandbox Testing subscription renewal transactions that happen when the app's not running are NEVER picked up by StoreKit2! That is, the transactions don't appear in StoreKit.Transaction.all
or Transaction.currentEntitlement(for:)
. This seems to have been a known issue since the release of StoreKit2. So, you can have situations where a user has paid to renew their subscription but StoreKit2 has no knowledge of it. However, this only seems to affect Xcode StoreKit testing and sandbox testing. Production builds using the live App Store DO NOT appear to suffer from this issue.
That's great, but you really want to be convinced during testing that your app works correctly! So, as a workaround, StoreHelper
now maintains a transactionUpdateCache
that keeps track of subscription transactions that happen when the app's not running. This cache is used in isPurchased(productId:)
when a call to Transaction.currentEntitlement(for: productId)
returns nil.
from storehelper.
Thanks Russel. Can confirm that's working nicely now. FWIW, I'd found a decent workaround by introspecting currentEntitlements. That seemed to work in the Debugger, etc... Eventually, entitlements would be updated, but likely not in the background as you've mentioned, so you do have to be more generous in checking subscription status. That is, not simply relying on the state at the very beginning of app execution. The following code was working consistently via an extension on StoreHelper...
public func purchasedSubscription() async -> Product? {
if self.hasStarted == false {
await self.start()
}
let result : Set<ProductId> = await self.currentEntitlements()
guard let productId = result.first else {
return nil
}
guard let products : [Product] = await self.requestProductsFromAppStore(productIds: [productId]) else {
return nil
}
guard let product = products.first else {
return nil
}
return product
}
from storehelper.
Related Issues (20)
- Subscription price button sometimes disappear after cancelling a subscription HOT 3
- TermsOfServiceView is not using the config overrides HOT 2
- Would you mind adding a small demo for using this with AppKit/macOS or UIKit/iOS? HOT 1
- Revocation not handled properly HOT 2
- Xcode Reports missing update task? HOT 2
- An issue that unconditionally returns true in shouldAddStorePayment method HOT 8
- Compile error: Configuration has no member named "value" HOT 1
- Subscription group HOT 3
- Do we have any idea on the next release HOT 1
- Missing repository reference HOT 3
- Missing products in production ready app HOT 3
- Certificate issue on device HOT 4
- Subscriptions renewed when the MacOS app was closed are not picked up by Storekit2 HOT 10
- How to implement custom transaction handler HOT 3
- Compile Issue HOT 1
- Question about using StoreHelper in Safari Extension project HOT 3
- Auto-renew subscription eligibility HOT 1
- "Writerly" hard-coded into StoreHelper HOT 1
- Can I use this without having the local Product.plist configuration file? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from storehelper.