Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Paywalls: only dismiss PaywallView when explicitly presenting it with .presentPaywallIfNeeded #3075

Merged
merged 2 commits into from
Aug 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions RevenueCatUI/View+PresentPaywall.swift
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ private struct PresentingPaywallModifier: ViewModifier {
)
.onPurchaseCompleted {
self.purchaseCompleted?($0)

self.isDisplayed = false
}
.toolbar {
ToolbarItem(placement: .destructiveAction) {
Expand Down
11 changes: 2 additions & 9 deletions RevenueCatUI/Views/PurchaseButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,6 @@ struct PurchaseButton: View {
self.purchaseHandler = purchaseHandler
}

@Environment(\.dismiss)
private var dismiss

var body: some View {
self.button
}
Expand All @@ -64,12 +61,8 @@ struct PurchaseButton: View {
AsyncButton {
guard !self.purchaseHandler.actionInProgress else { return }

let cancelled = try await self.purchaseHandler.purchase(package: self.package.content,
with: self.mode).userCancelled

if !cancelled, case .fullScreen = self.mode {
self.dismiss()
}
_ = try await self.purchaseHandler.purchase(package: self.package.content,
with: self.mode)
} label: {
IntroEligibilityStateView(
textWithNoIntroOffer: self.package.localization.callToAction,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ struct SamplePaywallsList: View {
purchaseHandler: .default())
}
}
.onPurchaseCompleted { _ in
self.display = nil
}
.navigationTitle("Paywalls")
}

Expand Down