Prevent paywall PurchaseHandler from being cleared on rerender#4035
Merged
Conversation
vegaro
reviewed
Jul 10, 2024
vegaro
reviewed
Jul 10, 2024
vegaro
reviewed
Jul 10, 2024
aboedo
approved these changes
Jul 10, 2024
vegaro
approved these changes
Jul 10, 2024
joshdholtz
added a commit
that referenced
this pull request
Jul 16, 2024
**This is an automatic release.** ### New Features * Paywalls with custom purchase and restore logic handlers (#3973) via James Borthwick (@jamesrb1) ### Bugfixes * Prevent paywall PurchaseHandler from being cleared on rerender (#4035) via Josh Holtz (@joshdholtz) * Update Purchase Tester for 5.0.0 (#4015) via Will Taylor (@fire-at-will) ### Dependency Updates * Bump fastlane from 2.221.0 to 2.221.1 (#3977) via dependabot[bot] (@dependabot[bot]) ### Other Changes * Bring official `xcodes` back to CI (#4029) via Cesar de la Vega (@vegaro) * Paywalls tester with sandbox purchases (#4024) via James Borthwick (@jamesrb1) * Update v5 migration guide to contain current latest version (#4019) via Toni Rico (@tonidero) * CI Build Docs Improvements (#4014) via Will Taylor (@fire-at-will) * Use available resource class for backend-integration-tests-offline-job (#4013) via Will Taylor (@fire-at-will) * Add `X-Preferred-Locales` header (#4008) via Cesar de la Vega (@vegaro) --------- Co-authored-by: Toni Rico <antonio.rico.diez@revenuecat.com> Co-authored-by: Josh Holtz <me@joshholtz.com>
jamesrb1
added a commit
that referenced
this pull request
Aug 8, 2024
Josh kindly [fixed a problem](#4035) while I was away where the purchase handler would get clobbered when the paywall was re-rendered. This PR restores avoiding having one struct owned by two @StateObjects at the same time.
nyeu
pushed a commit
that referenced
this pull request
Oct 2, 2024
### Motivation Fixes #4034 `PurchaseHandler` was being cleared/reset when a paywall was being rendered (ex: if an overlay was applied to it) ### Description - Restores `PurchaseHandler` back to being a `@StateObject` from #3187 - `checkForConfigurationConsistency()` has a few changes - Takes a `PurchaseHandler` as a parameter so it doesn't try to access the `StateObject` - This was fixes the purple Xcode warning of being access wrongly by it being a `StateObject` again - Removes `mutating` keyword and returns an `NSError?` which it now sets in the constructor ### Demo #### Using RevenueCat https://github.com/RevenueCat/purchases-ios/assets/401294/7e6430ca-6243-49ad-b7c0-8a90d90894f8 #### Using MyApp https://github.com/RevenueCat/purchases-ios/assets/401294/829f12c3-a11a-4952-883c-7ae7addd9c1d
nyeu
pushed a commit
that referenced
this pull request
Oct 2, 2024
**This is an automatic release.** ### New Features * Paywalls with custom purchase and restore logic handlers (#3973) via James Borthwick (@jamesrb1) ### Bugfixes * Prevent paywall PurchaseHandler from being cleared on rerender (#4035) via Josh Holtz (@joshdholtz) * Update Purchase Tester for 5.0.0 (#4015) via Will Taylor (@fire-at-will) ### Dependency Updates * Bump fastlane from 2.221.0 to 2.221.1 (#3977) via dependabot[bot] (@dependabot[bot]) ### Other Changes * Bring official `xcodes` back to CI (#4029) via Cesar de la Vega (@vegaro) * Paywalls tester with sandbox purchases (#4024) via James Borthwick (@jamesrb1) * Update v5 migration guide to contain current latest version (#4019) via Toni Rico (@tonidero) * CI Build Docs Improvements (#4014) via Will Taylor (@fire-at-will) * Use available resource class for backend-integration-tests-offline-job (#4013) via Will Taylor (@fire-at-will) * Add `X-Preferred-Locales` header (#4008) via Cesar de la Vega (@vegaro) --------- Co-authored-by: Toni Rico <antonio.rico.diez@revenuecat.com> Co-authored-by: Josh Holtz <me@joshholtz.com>
nyeu
pushed a commit
that referenced
this pull request
Oct 2, 2024
Josh kindly [fixed a problem](#4035) while I was away where the purchase handler would get clobbered when the paywall was re-rendered. This PR restores avoiding having one struct owned by two @StateObjects at the same time.
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.
Motivation
Fixes #4034
PurchaseHandlerwas being cleared/reset when a paywall was being re-rendered (ex: if an overlay was applied to it)Description
PurchaseHandlerback to being a@StateObjectfromPaywalls: fixed data flow resulting in multiplePurchaseHandlerinstances #3187checkForConfigurationConsistency()has a few changesPurchaseHandleras a parameter so it doesn't try to access theStateObjectStateObjectagainmutatingkeyword and returns anNSError?which it now sets in the constructorDemo
Using RevenueCat
Screen.Recording.2024-07-10.at.7.24.13.AM.mov
Using MyApp
Screen.Recording.2024-07-10.at.7.23.31.AM.mov