Fix: Fire paywall_decline when swiping down modal paywalls #426
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.
Summary
presentationController?.delegatefor modal/drawer presentation styles so UIKit notifies us on swipe-to-dismisspresentationControllerDidDismisshandler to firepaywall_declinewhen a modal is dismissed by swipe (without a survey)didAttemptToDismiss(survey path) already triggered dismissTest plan
paywall_declinefirespaywall_declinefires only oncepaywall_declinefires🤖 Generated with Claude Code
Greptile Overview
Greptile Summary
Enables
paywall_declineevent tracking when users swipe down modal/drawer paywalls by setting the presentation controller delegate and implementing thepresentationControllerDidDismisscallback.Key changes:
willShowSurveystate before setting delegate to preserve survey detection logic (fixing previous thread concern)presentationController?.delegate = selffor modal/drawer styles to receive swipe-to-dismiss notifications from UIKitpresentationControllerDidDismissto firepaywall_declinewhen swipe completescloseReasonwas already set bydidAttemptToDismiss(survey flow)Survey flow preserved:
isModalInPresentation = true→ swipe triggersdidAttemptToDismiss→ shows survey → subsequentdidDismissis guardedisModalInPresentation = false→ swipe completes →didDismissfirespaywall_declineConfidence Score: 4/5
Important Files Changed
Sequence Diagram
sequenceDiagram participant User participant UIKit participant PaywallVC participant Superwall Note over PaywallVC: presentationWillBegin() PaywallVC->>PaywallVC: Check willShowSurvey (before delegate set) alt Modal/Drawer Style PaywallVC->>PaywallVC: Set presentationController.delegate = self alt Has Survey PaywallVC->>PaywallVC: isModalInPresentation = true else No Survey PaywallVC->>PaywallVC: isModalInPresentation = false end end Note over User,UIKit: User swipes down to dismiss alt With Survey (isModalInPresentation=true) User->>UIKit: Swipe down UIKit->>PaywallVC: presentationControllerDidAttemptToDismiss() PaywallVC->>PaywallVC: dismiss(result: .declined, closeReason: .manualClose) PaywallVC->>PaywallVC: Set paywall.closeReason = .manualClose PaywallVC->>Superwall: track(paywall_decline) PaywallVC->>User: Show survey User->>UIKit: Complete survey & swipe again UIKit->>PaywallVC: presentationControllerDidDismiss() PaywallVC->>PaywallVC: Guard: closeReason != .none (already set) Note over PaywallVC: Early return, no duplicate event else Without Survey (isModalInPresentation=false) User->>UIKit: Swipe down UIKit->>UIKit: Dismissal completes UIKit->>PaywallVC: presentationControllerDidDismiss() PaywallVC->>PaywallVC: Guard: closeReason == .none (passes) PaywallVC->>PaywallVC: dismiss(result: .declined, closeReason: .manualClose) PaywallVC->>Superwall: track(paywall_decline) PaywallVC->>UIKit: Dismiss paywall end