Skip to content

Prevent paywall PurchaseHandler from being cleared on rerender#4035

Merged
joshdholtz merged 5 commits into
mainfrom
fix-paywall-handlers-being-cleared
Jul 10, 2024
Merged

Prevent paywall PurchaseHandler from being cleared on rerender#4035
joshdholtz merged 5 commits into
mainfrom
fix-paywall-handlers-being-cleared

Conversation

@joshdholtz

@joshdholtz joshdholtz commented Jul 10, 2024

Copy link
Copy Markdown
Member

Motivation

Fixes #4034

PurchaseHandler was being cleared/reset when a paywall was being re-rendered (ex: if an overlay was applied to it)

Description

  • Restores PurchaseHandler back to being a @StateObject from Paywalls: fixed data flow resulting in multiple PurchaseHandler instances #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

Screen.Recording.2024-07-10.at.7.24.13.AM.mov

Using MyApp

Screen.Recording.2024-07-10.at.7.23.31.AM.mov

@joshdholtz joshdholtz added the pr:fix A bug fix label Jul 10, 2024
@joshdholtz joshdholtz requested a review from a team July 10, 2024 12:30
Comment thread RevenueCatUI/PaywallView.swift Outdated
Comment thread RevenueCatUI/Data/PaywallViewConfiguration.swift
Comment thread RevenueCatUI/PaywallView.swift
Comment thread RevenueCatUI/PaywallView.swift
Comment thread RevenueCatUI/PaywallView.swift Outdated
@joshdholtz joshdholtz requested a review from vegaro July 10, 2024 14:11
@joshdholtz joshdholtz merged commit dbcfe0c into main Jul 10, 2024
@joshdholtz joshdholtz deleted the fix-paywall-handlers-being-cleared branch July 10, 2024 15:45
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr:fix A bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

paywallFooter handlers like purchaseCompleted or purchaseCancelled are not called with the release 5.0.0

3 participants