Skip to content

Conversation

@MojtabaHs
Copy link

@MojtabaHs MojtabaHs commented Nov 15, 2025

There are a bunch of methods to display the paywall, including:

  • Using the presentPaywallIfNeeded modifier
  • Building a PaywallView with configuration and presenting it manually
  • Building a PaywallView with arguments and presenting it manually
  • etc.

But only some of them have the ability to hide or show the closeButton since it is hardcoded into the PaywallView's initializer and cannot be reached from the helpers like the presentPaywallIfNeeded. Also, it is not how SwiftUI is designed.

So I have introduced a modifier called purchaseDisplayCloseButton so users can decide to hide/show the button anywhere they need to.

As an example, we can do this now:

.presentPaywallIfNeeded(
    requiredEntitlementIdentifier: Constants.ENTITLEMENT_ID,
    purchaseCompleted: { customerInfo in
        print("Purchase completed: \(customerInfo.entitlements)")
    },
    restoreCompleted: { customerInfo in
        // Paywall will be dismissed automatically if the entitlement is now active.
        print("Purchases restored: \(customerInfo.entitlements)")
    }
)
.purchaseDisplayCloseButton(false) // 👈 here is the modifier

I've also made it optional, so they can nil out this override to let the library use its default value if needed.

@MojtabaHs MojtabaHs requested a review from a team as a code owner November 15, 2025 12:42
@JZDesign
Copy link
Contributor

Hey @MojtabaHs!

Thanks for opening a PR when you found something you wanted improved. I noticed this is for our V1 version of paywalls, which we deprecated a while ago. In our V2 of paywalls, we allow you to delay the visibility of the close button via the editor.

Have you tried giving our new paywalls a shot yet?

https://www.revenuecat.com/docs/tools/paywalls

@MojtabaHs
Copy link
Author

JZDesign I'm using the v2. This new change works for the loading page in v2 in addition to the actual v1 paywallView. I couldn't find any way to hide the close button placeholder in the v2 except for this change. Am I missing something?

@JZDesign
Copy link
Contributor

JZDesign I'm using the v2. This new change works for the loading page in v2 in addition to the actual v1 paywallView. I couldn't find any way to hide the close button placeholder in the v2 except for this change. Am I missing something?

Hmm... Maybe I misread the code… Looks like it's only applying to the V1 view to me. I'll look again.

But if you are using paywalls v2, find the button with a navigate back action, then you'll find this at the bottom of the properties pane.

Screenshot 2025-11-17 at 7 55 34 AM

@MojtabaHs
Copy link
Author

But if you are using paywalls v2, find the button with a navigate back action, then you'll find this at the bottom of the properties pane.

Yeap, and I can even remove the button completely remotely with the editor (which I did 💪). But since we need a seamless loading screen, I've found that introducing an environment variable to override the hardcoded behavior is the best way with the minimal changes to the current one.

@JZDesign
Copy link
Contributor

JZDesign commented Nov 17, 2025

But if you are using paywalls v2, find the button with a navigate back action, then you'll find this at the bottom of the properties pane.

Yeap, and I can even remove the button completely remotely with the editor (which I did 💪). But since we need a seamless loading screen, I've found that introducing an environment variable to override the hardcoded behavior is the best way with the minimal changes to the current one.

Ah, if you want a seamless loading screen, you could not present the paywall at all until it's loaded:

MyView().task {
    isLoading = true
    Purchases.shared
        .getOfferings { _, error in
            isLoading = false
            if let error {
                handleError(error)
            } else {
                displayPaywall = true
            }
        }
}

I'll chat with the team about this change though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants