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.
Changes in this pull request
In SK2 we can't access the purchase from the transaction updates observer. Instead, we observe SK2 purchases if the app is using SK2 and if the
shouldObservePurchases
SuperwallOption
is set totrue
.The first thing that happens is we cache legacy transactions. This ensures transactions from before an SDK upgrade are cached to maintain consistency, avoiding redundant processing.
Then when the app enters the foreground it detects and processes unobserved transactions. First, this checks that there's no Superwall purchase happening. Then it checks that it gets a list of previously cached transactions to check we haven't already processed it. Then it checks the decoded jwsRepresentation paywall of the transaction to make sure it's a purchase instead of a renewal and extract whether an offer was purchased. Then we log a transaction start/complete for the given transaction.
Checklist
CHANGELOG.md
for any breaking changes, enhancements, or bug fixes.swiftlint
in the main directory and fixed any issues.