Skip to content

Conversation

JayShortway
Copy link
Member

@JayShortway JayShortway commented Jul 15, 2025

Description

This opens the door to showing PaywallView in a new Window, instead of in an Activity. It should also fix a few crashes we've been seeing in react-native-purchases, when the Paywall is shown modally.

There's an explainer added to the documentation of CompatComposeView.

@JayShortway JayShortway requested a review from vegaro July 15, 2025 12:09
@JayShortway JayShortway self-assigned this Jul 15, 2025
Copy link

emerge-tools bot commented Jul 15, 2025

📸 Snapshot Test

648 unchanged

Name Added Removed Modified Renamed Unchanged Errored Approval
TestPurchasesUIAndroidCompatibility
com.revenuecat.testpurchasesuiandroidcompatibility
0 0 0 0 397 0 N/A
TestPurchasesUIAndroidCompatibility Paparazzi
com.revenuecat.testpurchasesuiandroidcompatibility.paparazzi
0 0 0 0 251 0 N/A

🛸 Powered by Emerge Tools

@vegaro
Copy link
Contributor

vegaro commented Jul 15, 2025

just tested this as an alternative fix to RevenueCat/react-native-purchases#1319 and it seems to work fine

Copy link

codecov bot commented Jul 15, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 78.10%. Comparing base (b9a831c) to head (5daa3f1).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2527   +/-   ##
=======================================
  Coverage   78.10%   78.10%           
=======================================
  Files         286      286           
  Lines       10573    10573           
  Branches     1485     1485           
=======================================
  Hits         8258     8258           
  Misses       1668     1668           
  Partials      647      647           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@JayShortway JayShortway requested a review from a team July 15, 2025 14:32
@JayShortway JayShortway marked this pull request as ready for review July 15, 2025 14:32
@JayShortway
Copy link
Member Author

JayShortway commented Jul 15, 2025

@vegaro @tonidero I tested the regular scenario of adding a PaywallView to an Activity (which already worked before), and that still works. Even through configuration changes. If you can think of other scenarios to test that would be great.

Copy link
Contributor

@tonidero tonidero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing work! Code looks low level, but it all seems to make sense in my mind! A few scenarios we should make sure work:

  • In paywalls V1 footers, make sure the transition from loading to loaded states work correctly.
  • Make sure memory, viewmodel and listeners (if any) are released when paywall view is removed from the view tree
  • Localization works correctly (so if changing device locale, paywall is updated correctly)

Will mention more if I think of any

Copy link
Contributor

@tonidero tonidero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Just we should make sure we test all hybrids with this new approach

@JayShortway
Copy link
Member Author

I tested these:

  • In paywalls V1 footers, make sure the transition from loading to loaded states work correctly.
  • Make sure memory, viewmodel and listeners (if any) are released when paywall view is removed from the view tree
  • Localization works correctly (so if changing device locale, paywall is updated correctly)

And @vegaro tested the hybrids.

All seems to work fine!

* a modal in this case.
*/
@Suppress("TooManyFunctions")
@InternalRevenueCatAPI
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm I'm wondering if we should make this CompatComposeView a child of PaywallView and the others instead of making it a subclass... That way we wouldn't need to expose it. Having said I'm also ok leaving it like this! probably cleaner, even though it forces us to expose this API.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean an inner class? I'm not sure if that would work either, because PaywallView would still need to extend it, which makes it part of the API again.

If you mean child, it would be an empty view basically, right? It was written with the intention that it's the single root of a screen-level view. If it becomes a child it would be more brittle I think. (E.g. what happens if we accidentally add 2 children, at some point in the future when we've forgotten the details of how this works?)

Let me know!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I meant children. As in, we could have the PaywallView/CustomerCenterView have an instance of this view, which in turn would have a compose view inside... But yeah, I think having it as a subclass makes sense! Just some random thoughts I had 😅

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh got it, thanks! Yea I think having it as a superclass is simpler for now. We can always change it, as we "provide no guarantees" for @InternalRevenueCatAPI 😄

Copy link
Contributor

@vegaro vegaro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested this with the hybrids and seems to work fine

@JayShortway JayShortway added this pull request to the merge queue Jul 16, 2025
Merged via the queue into main with commit 6a5e235 Jul 16, 2025
14 checks passed
@JayShortway JayShortway deleted the compat-compose-view branch July 16, 2025 12:11
github-merge-queue bot pushed a commit that referenced this pull request Jul 17, 2025
**This is an automatic release.**

## RevenueCat SDK
### Virtual Currency
#### ✨ New Features
* Virtual Currency Support (#2519) via Will Taylor (@fire-at-will)

## RevenueCatUI SDK
### Paywallv2
#### ✨ New Features
* PaywallActivityLauncher: Add `edgeToEdge` parameter to display paywall
in full screen (#2530) via Toni Rico (@tonidero)
#### 🐞 Bugfixes
* Remove logic to avoid repurchasing already subscribed products (#2492)
via Toni Rico (@tonidero)

### 🔄 Other Changes
* Dont run VC tests on load shedder integration tests (#2538) via Will
Taylor (@fire-at-will)
* Introduces `CompatComposeView` to handle scenarios where the view tree
is not set up (#2527) via JayShortway (@JayShortway)

Co-authored-by: revenuecat-ops <ops@revenuecat.com>
tonidero pushed a commit that referenced this pull request Aug 25, 2025
…e is not set up (#2527)

## Description
This opens the door to showing `PaywallView` in a new Window, instead of
in an Activity. It should also fix a few crashes we've been seeing in
react-native-purchases, when the Paywall is shown modally.

There's an explainer added to the documentation of `CompatComposeView`.
@tonidero tonidero mentioned this pull request Aug 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants