Skip to main content
Solved

Displaying different paywalls based on offering

  • 16 January 2024
  • 6 replies
  • 230 views

Forum|alt.badge.img+1

Hi all, I could not find this in the docs. I have 2 different paywalls and 2 different offerings. How do I call up a specific paywall within the app vs the other using UKIT or Swift/IOS? Thanks!

Best answer by cody

Hey @krishdtech-3e6383!

When using UIKit, you can pass an `offering` to the PaywallViewController initializer after fetching your offerings like this:

func openPaywall() async throws {
    let offerings = try await Purchases.shared.offerings()
    let myCustomOffering = offerings.offering(identifier: "customerOfferingIdentifier")

    let paywall = PaywallViewController(offering: myCustomOffering, displayCloseButton: true)
    self.present(paywall, animated: true)
}

 

View original
Did this post help you find an answer to your question?

6 replies

cody
RevenueCat Staff
Forum|alt.badge.img+8
  • RevenueCat Staff
  • 487 replies
  • Answer
  • January 18, 2024

Hey @krishdtech-3e6383!

When using UIKit, you can pass an `offering` to the PaywallViewController initializer after fetching your offerings like this:

func openPaywall() async throws {
    let offerings = try await Purchases.shared.offerings()
    let myCustomOffering = offerings.offering(identifier: "customerOfferingIdentifier")

    let paywall = PaywallViewController(offering: myCustomOffering, displayCloseButton: true)
    self.present(paywall, animated: true)
}

 


Forum|alt.badge.img+1

Thanks that works!


Forum|alt.badge.img
  • New Member
  • 3 replies
  • December 2, 2024
cody wrote:

Hey @krishdtech-3e6383!

When using UIKit, you can pass an `offering` to the PaywallViewController initializer after fetching your offerings like this:

func openPaywall() async throws {
    let offerings = try await Purchases.shared.offerings()
    let myCustomOffering = offerings.offering(identifier: "customerOfferingIdentifier")

    let paywall = PaywallViewController(offering: myCustomOffering, displayCloseButton: true)
    self.present(paywall, animated: true)
}

 

What about SwiftUI?


Michael Fogel
Forum|alt.badge.img+6
  • Dedicated Contributor
  • 382 replies
  • December 2, 2024

Hey ​@ricardoag ,

 

We have code examples for SwiftUI which can be found here: https://www.revenuecat.com/docs/tools/paywalls/displaying-paywalls#tag/Project/operation/list-projects

 

If you would like to display a specific offering in a paywall using SwiftUI, I recommend following code similar to the code below: 

import SwiftUI

import RevenueCat
import RevenueCatUI

struct YourPaywall: View {

    let offering: Offering

    var body: some View {
        ScrollView {
            // Your custom paywall design content
        }
        .paywallFooter(offering: offering, condensed: true) { customerInfo in
            // Purchase completed! Thank your user and dismiss your paywall
        }
    }

}

 


Forum|alt.badge.img
  • New Member
  • 3 replies
  • December 2, 2024
Michael Fogel wrote:

Hey ​@ricardoag ,

 

We have code examples for SwiftUI which can be found here: https://www.revenuecat.com/docs/tools/paywalls/displaying-paywalls#tag/Project/operation/list-projects

 

If you would like to display a specific offering in a paywall using SwiftUI, I recommend following code similar to the code below: 

import SwiftUI

import RevenueCat
import RevenueCatUI

struct YourPaywall: View {

    let offering: Offering

    var body: some View {
        ScrollView {
            // Your custom paywall design content
        }
        .paywallFooter(offering: offering, condensed: true) { customerInfo in
            // Purchase completed! Thank your user and dismiss your paywall
        }
    }

}

 

I think I have a different problem. Currently I am using the code below. I want to have two Paywalls to sell the same products but varying the text, because the same Paywall can be displayed in different places in the app. Can you help me do this?

 

        PaywallView()

            .onPurchaseCompleted { CustomerInfo in

                userViewModel.isSubscriptionActive = true

                self.isPaywallPresented = false

            }


cody
RevenueCat Staff
Forum|alt.badge.img+8
  • RevenueCat Staff
  • 487 replies
  • December 9, 2024

Hey ​@ricardoag,

If you want to display two separate paywalls, you’ll can either:

  1. Display PaywallView with different offerings with two separate `isPresented` modifiers, or
  2. Use Placements to set an offering for each location in your app: https://www.revenuecat.com/docs/tools/targeting/placements

Placements are likely the more flexible option, to prevent hardcoding specific offerings in your app. You’ll fetch offerings by placement, then display the paywall with that offering:

let placementOffering = offerings.getCurrentOffering(forPlacement: "onboarding_end")

 


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings