-
Notifications
You must be signed in to change notification settings - Fork 316
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Created CachingTrialOrIntroPriceEligibilityChecker
#2007
Conversation
58b80b8
to
45990bb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
@available(iOS 13.0, tvOS 13.0, watchOS 6.2, macOS 10.15, *) | ||
extension TrialOrIntroPriceEligibilityCheckerType { | ||
|
||
func checkEligibility(productIdentifiers: [String]) async -> [String: IntroEligibility] { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, this seems unused other than in tests?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's actually public API.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But that's the completion version, not this one with async right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oooh good catch! I moved this to just the test file.
0fc4943
to
3d7b147
Compare
…ons` This changes the default back to `StoreKit 1`. We decided to do this for the following reasons: - Purchasing with `PromotionalOffer`s does not work with StoreKit 2 due to an Apple bug (see #2020 (comment)) - `checkTrialOrIntroDiscountEligibility` is significantly slower with StoreKit 2 (#1893). We're adding optimizations to help with that (#2007), but the underlying logic will still be slow. - A rare race-condition where `StoreKit 2` does not have transactions after a purchase ([TRIAGE-82]). We have some workarounds (#1945), but it's still being investigated. _ Note: This effectively reverts 0ee540a. That commit made it easier to only change the default in one place which is why this PR is basically just one line._
…ons` (#2022) This changes the default back to `StoreKit 1`. We decided to do this for the following reasons: - Purchasing with `PromotionalOffer`s does not work with StoreKit 2 due to an Apple bug (see #2020 (comment)) - `checkTrialOrIntroDiscountEligibility` is significantly slower with `StoreKit 2` (#1893). We're adding optimizations to help with that (#2007), but the underlying logic will still be slow. - A rare race-condition where `StoreKit 2` does not have transactions after a purchase ([TRIAGE-82]). We have some workarounds (#1945), but it's still being investigated. _Note: This effectively reverts 0ee540a. That commit made it easier to only change the default in one place which is why this PR is basically just one line._ [TRIAGE-82]: https://revenuecats.atlassian.net/browse/TRIAGE-82?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
d45d8bf
to
b08f3e4
Compare
Oh wait we need to invalidate this cache when we make purchases or they expire of course 🤦🏻♂️ |
b08f3e4
to
7eee829
Compare
7eee829
to
40e74fd
Compare
This is ready for review again @RevenueCat/coresdk, I'm now clearing the cache when subscriptions change (using #2057), which should fix integration tests. |
3eddf69
to
2f68cc7
Compare
e348a00
to
f632a4a
Compare
Sources/Purchasing/CachingTrialOrIntroPriceEligibilityChecker.swift
Outdated
Show resolved
Hide resolved
2f68cc7
to
eca596c
Compare
f632a4a
to
5409752
Compare
a9938b8
to
376e162
Compare
070785d
to
4eeacdf
Compare
4eeacdf
to
cb25a28
Compare
@@ -1235,6 +1238,11 @@ internal extension Purchases { | |||
|
|||
private extension Purchases { | |||
|
|||
func handleCustomerInfoChanged(_ customerInfo: CustomerInfo) { | |||
self.trialOrIntroPriceEligibilityChecker.clearCache() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aboedo per our discussion, this ordering now ensures there are no race conditions.
Updated this to clear caches using the existing |
**This is an automatic release.** ### New Features * Added new `ReceiptParser.fetchAndParseLocalReceipt` (#2204) via NachoSoto (@NachoSoto) * `PurchasesReceiptParser`: added API to parse receipts from `base64` string (#2200) via NachoSoto (@NachoSoto) ### Bugfixes * `CustomerInfo`: support parsing schema version 2 to restore SDK `v3.x` compatibility (#2213) via NachoSoto (@NachoSoto) ### Other Changes * `JSONDecoder`: added decoding type when logging `DecodingError.keyNotFound` (#2212) via NachoSoto (@NachoSoto) * Added `ReceiptParserTests` (#2203) via NachoSoto (@NachoSoto) * Deploy `PurchaseTester` for `macOS` (#2011) via NachoSoto (@NachoSoto) * `ReceiptFetcher`: refactored implementation to log error when failing to fetch receipt (#2202) via NachoSoto (@NachoSoto) * `PostReceiptDataOperation`: replaced receipt `base64` with `hash` for cache key (#2199) via NachoSoto (@NachoSoto) * `PurchaseTester`: small refactor to simplify `Date` formatting (#2210) via NachoSoto (@NachoSoto) * `PurchasesReceiptParser`: improved documentation to reference `default` (#2197) via NachoSoto (@NachoSoto) * Created `CachingTrialOrIntroPriceEligibilityChecker` (#2007) via NachoSoto (@NachoSoto) * Update Gemfile.lock (#2205) via Cesar de la Vega (@vegaro) * remove stalebot in favor of SLAs in Zendesk (#2196) via Andy Boedo (@aboedo) * Update fastlane-plugin-revenuecat_internal to latest version (#2194) via Cesar de la Vega (@vegaro)
This will help provide a better experience when launching paywalls, as hopefully we will have already computed intro eligibility by then. This is even better than when using `StoreKit` paywalls. Note that thanks to `CachingTrialOrIntroPriceEligibilityChecker` (#2007) this is cached automatically, and also it handles multiple requests with the same or different product identifiers.
Fixes CSDK-493.
This will help a little bit with the SK2 performance issues computing eligibility (#1893).