Disable SK1's StoreKitWrapper if SK2 is enabled and available#1882
Merged
Conversation
Contributor
Author
|
I believe all tests should pass. |
Member
|
I think having a separate wrapper for the ones that are SK1-only should work. The only reason we have a wrapper for them in the first place is to make mocking easier, and that function can still be served by a separate wrapper |
StoreKitWrapper if SK2 is enabled and availableStoreKitWrapper if SK2 is enabled and available
0e4f57d to
5a7a024
Compare
NachoSoto
added a commit
that referenced
this pull request
Sep 4, 2022
StoreKitWrapper if SK2 is enabled and availableStoreKitWrapper if SK2 is enabled and available
5a7a024 to
cfdaabc
Compare
Contributor
Author
|
This is ready now. |
db4d86d to
282f63f
Compare
aboedo
approved these changes
Sep 5, 2022
Member
There was a problem hiding this comment.
starting to think we should rename this to storeKit1Wrapper
Contributor
Author
There was a problem hiding this comment.
Yeah that's a good idea, let me do that.
Contributor
Author
There was a problem hiding this comment.
Actually let me send a separate PR for that so we can keep the history of this particular change easier to follow in the future.
When SK2 is enabled, `StoreKit2TransactionListener` is enough to handle transactions, so it's not longer necessary to have that and `StoreKitWrapper` both listening to them.
282f63f to
cd6d097
Compare
NachoSoto
added a commit
that referenced
this pull request
Sep 6, 2022
Follow up to #1882. Now that `StoreKit1Wrapper` is not initialized for SK2, it makes sense to clarify that this class is only for SK1. This is just a simple find-replace.
NachoSoto
added a commit
that referenced
this pull request
Sep 6, 2022
Follow up to #1882. Now that `StoreKit1Wrapper` is not initialized for SK2, it makes sense to clarify that this class is only for SK1. This is just a simple find-replace.
NachoSoto
pushed a commit
that referenced
this pull request
Sep 8, 2022
**This is an automatic release.** ### Bugfixes * `watchOS`: fixed crash when ran on single-target apps with Xcode 14 and before `watchOS 9.0` (#1895) via NachoSoto (@NachoSoto) * `CustomerInfoManager`/`OfferingsManager`: improved display of underlying errors (#1888) via NachoSoto (@NachoSoto) * `Offering`: improved confusing log for `PackageType.custom` (#1884) via NachoSoto (@NachoSoto) * `PurchasesOrchestrator`: don't log warning if `allowSharingAppStoreAccount` setting was never explicitly set (#1885) via NachoSoto (@NachoSoto) * Introduced type-safe `PurchasesError` and fixed some incorrect returned error types (#1879) via NachoSoto (@NachoSoto) * `CustomerInfoManager`: fixed thread-unsafe implementation (#1878) via NachoSoto (@NachoSoto) ### New Features * Disable SK1's `StoreKitWrapper` if SK2 is enabled and available (#1882) via NachoSoto (@NachoSoto) * `Sendable` support (#1795) via NachoSoto (@NachoSoto) ### Other Changes * Renamed `StoreKitWrapper` to `StoreKit1Wrapper` (#1886) via NachoSoto (@NachoSoto) * Enabled `DEAD_CODE_STRIPPING` (#1887) via NachoSoto (@NachoSoto) * `HTTPClient`: added `X-Client-Bundle-ID` and logged on SDK initialization (#1883) via NachoSoto (@NachoSoto) * add link to SDK reference (#1872) via Andy Boedo (@aboedo) * Added `StoreKit2Setting.shouldOnlyUseStoreKit2` (#1881) via NachoSoto (@NachoSoto) * Introduced `TestLogHandler` to simplify how we test logged messages (#1858) via NachoSoto (@NachoSoto) * `Integration Tests`: added test for purchasing `StoreProduct` instead of `Package` (#1875) via NachoSoto (@NachoSoto) * `ErrorUtils`: added test to verify that returned errors can be converted to `ErrorCode` (#1871) via NachoSoto (@NachoSoto)
Merged
5 tasks
NachoSoto
added a commit
that referenced
this pull request
Sep 19, 2022
…Store when SK1 is disabled Follow up to #1882. After that PR, `StoreKit1Wrapper` was no longer listening to `SKPaymentQueueDelegate.paymentQueue(:shouldAddStorePayment:for:)`, which means that purchases initiated from the App Store were being ignored by the SDK if SK2 is enabled. To fix this, `PaymentQueueWrapper` now becomes the `SKPaymentQueueDelegate` only when `StoreKit1Wrapper` is not initialized, and `PurchasesOrchestrator` initiates an SK2 purchase instead. - `PurchasesOrchestrator` purchase methods no longer need the whole `PromotionalOffer`, only the `SignedData`. This allows the new implementation to create that data from only the `SKPaymentDiscount` provided from the `SKPayment`. - [ ] Test that `StoreKit1Wrapper` is the delegate if SK1 is enabled - [ ] Test that `PaymentQueueWrapper` is the delegate otherwise - [ ] Test `PromotionalOffer.SignedData` initialization from SK1 - [ ] Test conversion of SK1 product to SK2.
NachoSoto
added a commit
that referenced
this pull request
Sep 21, 2022
…Store when SK1 is disabled (#1901) Follow up to #1882. After that PR, `StoreKit1Wrapper` was no longer listening to `SKPaymentQueueDelegate.paymentQueue(:shouldAddStorePayment:for:)`, which means that purchases initiated from the App Store were being ignored by the SDK if SK2 is enabled. To fix this, `PaymentQueueWrapper` now becomes the `SKPaymentQueueDelegate` only when `StoreKit1Wrapper` is not initialized, and `PurchasesOrchestrator` initiates an SK2 purchase instead. ## Other changes: - `PurchasesOrchestrator` purchase methods no longer need the whole `PromotionalOffer`, only the `SignedData`. This allows the new implementation to create that data from only the `SKPaymentDiscount` provided from the `SKPayment`. - Added tests for `PromotionalOffer.SignedData`
NachoSoto
added a commit
that referenced
this pull request
Sep 30, 2022
Follow up to. This is also needed when `StoreKit1Wrapper` is not setup (see #1882).
NachoSoto
added a commit
that referenced
this pull request
Oct 7, 2022
Follow up to. This is also needed when `StoreKit1Wrapper` is not setup (see #1882).
NachoSoto
added a commit
that referenced
this pull request
Oct 7, 2022
…e` wrapper This is a follow up to #1901 and #1882. Essentially before this change, `Purchases` had both `StoreKit1Wrapper?` and a `PaymentQueueWrapper`. The later wasn't actually needed when the first was not-nil, so it was essentially storing `(a?, b?)`. What we really wanted to express is that it could have one OR the other. This introduces `Either` to express this requirement in the type system, as well as `PaymentQueueWrapperType` that will be used to fix #1964.
NachoSoto
added a commit
that referenced
this pull request
Oct 10, 2022
…e` wrapper This is a follow up to #1901 and #1882. Essentially before this change, `Purchases` had both `StoreKit1Wrapper?` and a `PaymentQueueWrapper`. The later wasn't actually needed when the first was not-nil, so it was essentially storing `(a?, b?)`. What we really wanted to express is that it could have one OR the other. This introduces `Either` to express this requirement in the type system, as well as `PaymentQueueWrapperType` that will be used to fix #1964.
NachoSoto
added a commit
that referenced
this pull request
Oct 11, 2022
…e` wrapper (#1968) This is a follow up to #1901 and #1882. Depends on #1967. Essentially before this change, `Purchases` had both `StoreKit1Wrapper?` and a `PaymentQueueWrapper`. The later wasn't actually needed when the first was not-nil, so it was essentially storing `(a?, b?)`. What we really wanted to express is that it could have one OR the other. This introduces `Either` to express this requirement in the type system, as well as `PaymentQueueWrapperType` that will be used to fix #1964.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When SK2 is enabled,
StoreKit2TransactionListeneris enough to handle transactions, so it's no longer necessary to have that andStoreKitWrapperboth listening to them.Depends on #1881 and #1879.
TODO:
presentCodeRedemptionSheetandshowPriceConsentIfNeeded? We could have a dedicated "SK1Wrapper" with support for only those 2 functions, since they don't have an SK2 equivalent.