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

[FEATURE REQUEST] Provide paywall view controller in SuperwallDelegate.handleCustomPaywallAction #294

Open
vrutberg opened this issue Feb 13, 2025 · 2 comments

Comments

@vrutberg
Copy link

vrutberg commented Feb 13, 2025

We're currently integrating with Superwall, and have come up with a possible improvement in the SDK. We've looked around in the SDK and documentation and haven't found a straightforward way to achieve what we are suggesting, but of course we might have missed an obvious solution to this problem. In that case, feel free to close this issue.

Is your feature request related to a problem? Please describe.
We're implementing a paywall with some custom actions that leads to navigation within the app. In some cases, these custom actions will lead to something being pushed on the navigation stack of the paywall view controller. To avoid bookkeeping of what paywall view controller is being presented, it would be nice to receive this information from the SDK.

Describe the solution you'd like
I'm thinking that the delegate method handleCustomPaywallAction of SuperwallDelegate could be augmented with another argument: in paywallViewController: PaywallViewController.

Before:

extension SuperwallManager: SuperwallDelegate {
    func handleCustomPaywallAction(withName name: String) {
        switch action {
        case "feedback":
            // How do I push something on to the navigation stack from here?
            break
        default:
            break
        }
    }
}

After:

extension SuperwallManager: SuperwallDelegate {
    func handleCustomPaywallAction(
        withName name: String,
        in paywallViewController: PaywallViewController
    ) {
        switch action {
        case "feedback":
            paywalViewController.navigationController?.pushViewController(..., animated: true)
        default:
            break
        }
    }
}

Describe alternatives you've considered
It is possible to do some bookkeeping to keep track of the current paywall being presented, and push on the navigation stack. It's just more work.

Another alternative could be to move this delegate method to the PaywallViewControllerDelegate.

@yusuftor
Copy link
Collaborator

yusuftor commented Feb 14, 2025

Are you using getPaywall to get the paywall and push it onto the stack? Or you're using register but you want to access a navigation controller that the paywall is part of? You can always get the presented paywall by calling Superwall.shared.paywallViewController.

@vrutberg
Copy link
Author

Thanks for looking into this @yusuftor.

We are indeed using getPaywall to manually display the paywall. Sometimes the paywall is pushed onto an existing navigation stack, and other times, it is presented as the first view controller in a new navigation stack.

Oh, I don't think we were aware of Superwall.shared.paywallViewController. That might be what we were looking for. I'll take a look at that.

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

No branches or pull requests

2 participants